shlink-web-client/test/common/NotFound.test.js

49 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-03-03 13:02:29 +03:00
import React from 'react';
import { shallow } from 'enzyme';
import { Link } from 'react-router-dom';
import NotFound from '../../src/common/NotFound';
describe('<NotFound />', () => {
let wrapper;
const createWrapper = (props = {}) => {
wrapper = shallow(<NotFound {...props} />);
const content = wrapper.text();
2019-03-03 13:02:29 +03:00
return { wrapper, content };
};
afterEach(() => wrapper && wrapper.unmount());
2019-03-03 13:02:29 +03:00
it('shows expected error title', () => {
const { content } = createWrapper();
2019-03-03 13:02:29 +03:00
expect(content).toContain('Oops! We could not find requested route.');
});
it('shows expected error message', () => {
const { content } = createWrapper();
2019-03-03 13:02:29 +03:00
expect(content).toContain(
'Use your browser\'s back button to navigate to the page you have previously come from, or just press this button.'
);
});
2019-03-03 13:02:29 +03:00
it('shows a link to the home', () => {
const { wrapper } = createWrapper();
2019-03-03 13:02:29 +03:00
const link = wrapper.find(Link);
expect(link.prop('to')).toEqual('/');
expect(link.prop('className')).toEqual('btn btn-outline-primary btn-lg');
expect(link.prop('children')).toEqual('Home');
});
it('shows a link with provided props', () => {
2020-03-08 14:57:01 +03:00
const { wrapper } = createWrapper({ to: '/foo/bar', children: 'Hello' });
const link = wrapper.find(Link);
expect(link.prop('to')).toEqual('/foo/bar');
expect(link.prop('className')).toEqual('btn btn-outline-primary btn-lg');
expect(link.prop('children')).toEqual('Hello');
2019-03-03 13:02:29 +03:00
});
});