Used not-found component for menu layout inner router

This commit is contained in:
Alejandro Celaya
2019-03-03 11:15:34 +01:00
parent d23ddd0e0b
commit c4bc2f24d6
3 changed files with 45 additions and 12 deletions

View File

@@ -5,26 +5,44 @@ import NotFound from '../../src/common/NotFound';
describe('<NotFound />', () => {
let wrapper;
let content;
const createWrapper = (props = {}) => {
wrapper = shallow(<NotFound {...props} />);
const content = wrapper.text();
beforeEach(() => {
wrapper = shallow(<NotFound />);
content = wrapper.text();
return { wrapper, content };
};
afterEach(() => wrapper && wrapper.unmount());
it('shows expected error title', () => {
const { content } = createWrapper();
expect(content).toContain('Oops! We could not find requested route.');
});
afterEach(() => wrapper.unmount());
it('shows expected error message', () => {
const { content } = createWrapper();
it('shows expected error title', () => expect(content).toContain('Oops! We could not find requested route.'));
it('shows expected error message', () =>
expect(content).toContain(
'Use your browser\'s back button to navigate to the page you have previously come from, or just press this button.'
));
);
});
it('shows a link to the home', () => {
const { wrapper } = createWrapper();
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', () => {
const { wrapper } = createWrapper({ to: '/foo/bar', btnText: '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');
});
});