Skip to content

Commit 771b7a6

Browse files
committed
complete connected component test cases
1 parent 7fcce50 commit 771b7a6

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

chapter-05/todo_with_selector/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"devDependencies": {
6+
"enzyme": "^2.7.0",
7+
"react-addons-test-utils": "^15.4.2",
68
"react-scripts": "0.8.4",
79
"redux-immutable-state-invariant": "^1.2.4"
810
},

chapter-09/todo_react_motion/test/filter/views/filters.test.js renamed to chapter-05/todo_with_selector/test/filter/views/filters.test.js

File renamed without changes.

chapter-09/todo_react_motion/test/todos/actions.test.js renamed to chapter-05/todo_with_selector/test/todos/actions.test.js

File renamed without changes.

chapter-09/todo_react_motion/test/todos/views/todoList.test.js renamed to chapter-05/todo_with_selector/test/todos/views/todoList.test.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {mount} from 'enzyme';
33
import {createStore, combineReducers} from 'redux';
4+
import {Provider} from 'react-redux';
45

56
import {reducer as todosReducer, actions} from '../../../src/todos/index.js';
67
import {reducer as filterReducer} from '../../../src/filter/index.js';
@@ -9,8 +10,7 @@ import TodoList from '../../../src/todos/views/todoList.js';
910
import TodoItem from '../../../src/todos/views/todoItem.js';
1011

1112
describe('todos', () => {
12-
it('should add new todo item on click add button', () => {
13-
console.log('#', FilterTypes.ALL);
13+
it('should add new todo-item on addTodo action', () => {
1414
const store = createStore(
1515
combineReducers({
1616
todos: todosReducer,
@@ -19,14 +19,16 @@ describe('todos', () => {
1919
todos: [],
2020
filter: FilterTypes.ALL
2121
});
22-
const subject = <TodoList store={store} />;
22+
const subject = (
23+
<Provider store={store}>
24+
<TodoList store={store} />
25+
</Provider>
26+
);
2327
const wrapper = mount(subject);
2428

25-
store.dispatch(actions.addTodo('test all'));
29+
store.dispatch(actions.addTodo('write more test'));
2630

27-
console.log('#li', wrapper.find('.todo-item').text());
28-
console.log('###', wrapper.find('.text').text());
29-
expect(wrapper.find('.text').text()).toEqual('test all');
31+
expect(wrapper.find('.text').text()).toEqual('write more test');
3032
});
3133

3234
});

0 commit comments

Comments
 (0)