11import React from 'react' ;
22import { mount } from 'enzyme' ;
33import { createStore , combineReducers } from 'redux' ;
4+ import { Provider } from 'react-redux' ;
45
56import { reducer as todosReducer , actions } from '../../../src/todos/index.js' ;
67import { reducer as filterReducer } from '../../../src/filter/index.js' ;
@@ -9,8 +10,7 @@ import TodoList from '../../../src/todos/views/todoList.js';
910import TodoItem from '../../../src/todos/views/todoItem.js' ;
1011
1112describe ( '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