1- import  {  fromJS  }  from  'immutable' ; 
2- 
31import  appReducer  from  '../reducer' ; 
4- import  { 
5-   loadRepos , 
6-   reposLoaded , 
7-   repoLoadingError , 
8- }  from  '../actions' ; 
2+ import  {  loadRepos ,  reposLoaded ,  repoLoadingError  }  from  '../actions' ; 
93
104describe ( 'appReducer' ,  ( )  =>  { 
115  let  state ; 
126  beforeEach ( ( )  =>  { 
13-     state  =  fromJS ( { 
7+     state  =  { 
148      loading : false , 
159      error : false , 
1610      currentUser : false , 
17-       userData : fromJS ( { 
11+       userData : { 
1812        repositories : false , 
19-       } ) , 
20-     } ) ; 
13+       } , 
14+     } ; 
2115  } ) ; 
2216
2317  it ( 'should return the initial state' ,  ( )  =>  { 
@@ -26,35 +20,47 @@ describe('appReducer', () => {
2620  } ) ; 
2721
2822  it ( 'should handle the loadRepos action correctly' ,  ( )  =>  { 
29-     const  expectedResult  =  state 
30-       . set ( 'loading' ,  true ) 
31-       . set ( 'error' ,  false ) 
32-       . setIn ( [ 'userData' ,  'repositories' ] ,  false ) ; 
33- 
23+     const  expectedResult  =  { 
24+       ...state , 
25+       loading : true , 
26+       error : false , 
27+       userData : {  repositories : false  } , 
28+     } ; 
3429    expect ( appReducer ( state ,  loadRepos ( ) ) ) . toEqual ( expectedResult ) ; 
3530  } ) ; 
3631
3732  it ( 'should handle the reposLoaded action correctly' ,  ( )  =>  { 
38-     const  fixture  =  [ { 
39-       name : 'My Repo' , 
40-     } ] ; 
33+     const  fixture  =  [ 
34+       { 
35+         name : 'My Repo' , 
36+       } , 
37+     ] ; 
4138    const  username  =  'test' ; 
42-     const  expectedResult  =  state 
43-       . setIn ( [ 'userData' ,  'repositories' ] ,  fixture ) 
44-       . set ( 'loading' ,  false ) 
45-       . set ( 'currentUser' ,  username ) ; 
39+     const  expectedResult  =  { 
40+       ...state , 
41+       loading : false , 
42+       currentUser : username , 
43+       userData : {  repositories : fixture  } , 
44+     } ; 
4645
47-     expect ( appReducer ( state ,  reposLoaded ( fixture ,  username ) ) ) . toEqual ( expectedResult ) ; 
46+     expect ( appReducer ( state ,  reposLoaded ( fixture ,  username ) ) ) . toEqual ( 
47+       expectedResult , 
48+     ) ; 
4849  } ) ; 
4950
5051  it ( 'should handle the repoLoadingError action correctly' ,  ( )  =>  { 
5152    const  fixture  =  { 
5253      msg : 'Not found' , 
5354    } ; 
54-     const  expectedResult  =  state 
55-       . set ( 'error' ,  fixture ) 
56-       . set ( 'loading' ,  false ) ; 
5755
58-     expect ( appReducer ( state ,  repoLoadingError ( fixture ) ) ) . toEqual ( expectedResult ) ; 
56+     const  expectedResult  =  { 
57+       ...state , 
58+       error : fixture , 
59+       loading : false , 
60+     } ; 
61+ 
62+     expect ( appReducer ( state ,  repoLoadingError ( fixture ) ) ) . toEqual ( 
63+       expectedResult , 
64+     ) ; 
5965  } ) ; 
6066} ) ; 
0 commit comments