Skip to content

Instantly share code, notes, and snippets.

@antonybudianto
Created August 11, 2017 13:36
Show Gist options
  • Save antonybudianto/2d099a023cc1c6b072169a7bf52db467 to your computer and use it in GitHub Desktop.
Save antonybudianto/2d099a023cc1c6b072169a7bf52db467 to your computer and use it in GitHub Desktop.
import React from 'react';
import ReactDOM from 'react-dom';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router';
import LandingPage from './LandingPage/LandingPage';
import NotFoundPage from './ErrorPage/NotFoundPage/NotFoundPage';
import App from './App';
jest.mock('firebase/app');
test('invalid path should redirect to 404', () => {
const wrapper = mount(
<MemoryRouter initialEntries={[ '/random' ]}>
<App/>
</MemoryRouter>
);
expect(wrapper.find(LandingPage)).toHaveLength(0);
expect(wrapper.find(NotFoundPage)).toHaveLength(1);
});
test('valid path should not redirect to 404', () => {
const wrapper = mount(
<MemoryRouter initialEntries={[ '/' ]}>
<App/>
</MemoryRouter>
);
expect(wrapper.find(LandingPage)).toHaveLength(1);
expect(wrapper.find(NotFoundPage)).toHaveLength(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment