@@ -8,12 +8,16 @@ describe('Connector', () => {
8
8
let store ;
9
9
let connect ;
10
10
let targetObj ;
11
+ let defaultState ;
11
12
12
13
beforeEach ( ( ) => {
13
- store = createStore ( ( state , action ) => ( {
14
+ defaultState = {
14
15
foo : 'bar' ,
15
- baz : action . payload
16
- } ) ) ;
16
+ baz : - 1
17
+ } ;
18
+ store = createStore ( ( state = defaultState , action ) => {
19
+ return { ...state , baz : action . payload } ;
20
+ } ) ;
17
21
targetObj = { } ;
18
22
connect = Connector ( store ) ;
19
23
} ) ;
@@ -45,8 +49,8 @@ describe('Connector', () => {
45
49
connect ( state => state ) ( targetObj ) ;
46
50
store . dispatch ( { type : 'ACTION' , payload : 0 } ) ;
47
51
expect ( targetObj . baz ) . toBe ( 0 ) ;
48
- store . dispatch ( { type : 'ACTION' , payload : 1 } ) ;
49
- expect ( targetObj . baz ) . toBe ( 1 ) ;
52
+ store . dispatch ( { type : 'ACTION' , payload : 7 } ) ;
53
+ expect ( targetObj . baz ) . toBe ( 7 ) ;
50
54
} ) ;
51
55
52
56
it ( 'Should prevent unnecessary updates when state does not change (shallowly)' , ( ) => {
@@ -90,11 +94,4 @@ describe('Connector', () => {
90
94
expect ( receivedDispatch ) . toBe ( store . dispatch ) ;
91
95
} ) ;
92
96
93
- it ( 'Should call target (Function) with mapStateToTarget and mapDispatchToTarget results ' , ( ) => {
94
-
95
- //let targetFunc = sinon.spy();
96
- //connect(targetFunc, state => state.pojo);
97
- expect ( false ) . toBe ( true ) ;
98
- } ) ;
99
-
100
97
} ) ;
0 commit comments