-
Notifications
You must be signed in to change notification settings - Fork 50
/
App.test.js
43 lines (36 loc) · 1.05 KB
/
App.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import { shallow, mount } from 'enzyme';
import { Provider } from 'react-redux';
import { connectRouter, ConnectedRouter } from 'connected-react-router';
import { Route, Redirect, Switch } from 'react-router-dom';
import App from './App';
import { getMockStore } from './test-utils/mocks';
import { history } from './store/store';
const mockStore = getMockStore({ todos: [], selectedTodo: null });
jest.mock('./containers/TodoList/TodoList', () => {
return jest.fn(props => {
return (
<div className="spyTodoList">
{props.title}
</div>);
});
});
describe('App', () => {
let app;
beforeEach(() => {
app = (
<Provider store={mockStore}>
<App history={history}/>
</Provider>
)
});
it('should render', () => {
const component = mount(app);
expect(component.find('.App').length).toBe(1);
});
it('should be redirected to error page', () => {
history.push('/aaa');
const component = mount(app);
expect(component.find('h1').text()).toBe('Not Found');
})
});