@@ -18,6 +18,8 @@ import {mock as RPCPluginMock, RPCHandlersToken} from '../index';
18
18
import Plugin from '../plugin' ;
19
19
import { withRPCRedux , withRPCReactor } from '../hoc' ;
20
20
21
+ const initActionPattern = / ^ @ @ r e d u x \/ I N I T .* / ;
22
+
21
23
function setup ( ) {
22
24
const root = document . createElement ( 'div' ) ;
23
25
root . id = 'root' ;
@@ -53,15 +55,17 @@ test('browser plugin integration test withRPCRedux', async t => {
53
55
} ;
54
56
55
57
const expectedActions = [
56
- { type : '@@redux/INIT' } ,
57
- { type : ' TEST_START' , payload : { hello : 'world' } } ,
58
- { type : ' TEST_SUCCESS' , payload : { a : 'b' } } ,
58
+ { type : initActionPattern } ,
59
+ { type : / T E S T _ S T A R T / , payload : { hello : 'world' } } ,
60
+ { type : / T E S T _ S U C C E S S / , payload : { a : 'b' } } ,
59
61
] ;
60
62
const store = createStore ( ( state , action ) => {
63
+ const fixture = expectedActions . shift ( ) ;
64
+ t . ok ( fixture . type . test ( action . type ) , 'dispatches expected action type' ) ;
61
65
t . deepLooseEqual (
62
- action ,
63
- expectedActions . shift ( ) ,
64
- 'dispatches expected action'
66
+ action . payload ,
67
+ fixture . payload ,
68
+ 'dispatches expected action payload '
65
69
) ;
66
70
return action . payload ;
67
71
} ) ;
@@ -119,18 +123,20 @@ test('browser plugin integration test withRPCRedux - failure', async t => {
119
123
} ;
120
124
121
125
const expectedActions = [
122
- { type : '@@redux/INIT' } ,
123
- { type : ' TEST_START' , payload : { hello : 'world' } } ,
126
+ { type : initActionPattern } ,
127
+ { type : / T E S T _ S T A R T / , payload : { hello : 'world' } } ,
124
128
{
125
- type : ' TEST_FAILURE' ,
129
+ type : / T E S T _ F A I L U R E / ,
126
130
payload : { message : 'message' , code : 'code' , meta : { hello : 'world' } } ,
127
131
} ,
128
132
] ;
129
133
const store = createStore ( ( state , action ) => {
134
+ const fixture = expectedActions . shift ( ) ;
135
+ t . ok ( fixture . type . test ( action . type ) , 'dispatches expected action type' ) ;
130
136
t . deepLooseEqual (
131
- action ,
132
- expectedActions . shift ( ) ,
133
- 'dispatches expected action'
137
+ action . payload ,
138
+ fixture . payload ,
139
+ 'dispatches expected action payload '
134
140
) ;
135
141
return action . payload ;
136
142
} ) ;
@@ -176,15 +182,17 @@ test('browser mock integration test withRPCRedux', async t => {
176
182
} ,
177
183
} ;
178
184
const expectedActions = [
179
- { type : '@@redux/INIT' } ,
180
- { type : ' TEST_START' , payload : { hello : 'world' } } ,
181
- { type : ' TEST_SUCCESS' , payload : { a : 'b' } } ,
185
+ { type : initActionPattern } ,
186
+ { type : / T E S T _ S T A R T / , payload : { hello : 'world' } } ,
187
+ { type : / T E S T _ S U C C E S S / , payload : { a : 'b' } } ,
182
188
] ;
183
189
const store = createStore ( ( state , action ) => {
190
+ const fixture = expectedActions . shift ( ) ;
191
+ t . ok ( fixture . type . test ( action . type ) , 'dispatches expected action type' ) ;
184
192
t . deepLooseEqual (
185
- action ,
186
- expectedActions . shift ( ) ,
187
- 'dispatches expected actions '
193
+ action . payload ,
194
+ fixture . payload ,
195
+ 'dispatches expected action payload '
188
196
) ;
189
197
return action . payload ;
190
198
} ) ;
@@ -232,18 +240,20 @@ test('browser mock integration test withRPCRedux - failure', async t => {
232
240
} ,
233
241
} ;
234
242
const expectedActions = [
235
- { type : '@@redux/INIT' } ,
236
- { type : ' TEST_START' , payload : { hello : 'world' } } ,
243
+ { type : initActionPattern } ,
244
+ { type : / T E S T _ S T A R T / , payload : { hello : 'world' } } ,
237
245
{
238
- type : ' TEST_FAILURE' ,
246
+ type : / T E S T _ F A I L U R E / ,
239
247
payload : { message : 'message' , code : 'code' , meta : { hello : 'world' } } ,
240
248
} ,
241
249
] ;
242
250
const store = createStore ( ( state , action ) => {
251
+ const fixture = expectedActions . shift ( ) ;
252
+ t . ok ( fixture . type . test ( action . type ) , 'dispatches expected action type' ) ;
243
253
t . deepLooseEqual (
244
- action ,
245
- expectedActions . shift ( ) ,
246
- 'dispatches expected actions '
254
+ action . payload ,
255
+ fixture . payload ,
256
+ 'dispatches expected action payload '
247
257
) ;
248
258
return action . payload ;
249
259
} ) ;
@@ -298,13 +308,12 @@ test('browser plugin integration test withRPCReactor', async t => {
298
308
) ;
299
309
} ;
300
310
301
- const expectedActions = [ { type : '@@redux/INIT' } ] ;
311
+ const expectedActions = [ { type : initActionPattern } ] ;
302
312
const store = createStore (
303
313
( state , action ) => {
304
- t . deepLooseEqual (
305
- action ,
306
- expectedActions . shift ( ) ,
307
- 'dispatches expected action'
314
+ t . ok (
315
+ expectedActions . shift ( ) . type . test ( action . type ) ,
316
+ 'dispatches expected action type'
308
317
) ;
309
318
return action . payload ;
310
319
} ,
@@ -385,13 +394,12 @@ test('browser mock plugin integration test withRPCReactor', async t => {
385
394
} ,
386
395
} ;
387
396
388
- const expectedActions = [ { type : '@@redux/INIT' } ] ;
397
+ const expectedActions = [ { type : initActionPattern } ] ;
389
398
const store = createStore (
390
399
( state , action ) => {
391
- t . deepLooseEqual (
392
- action ,
393
- expectedActions . shift ( ) ,
394
- 'dispatches expected action'
400
+ t . ok (
401
+ expectedActions . shift ( ) . type . test ( action . type ) ,
402
+ 'dispatches expected action type'
395
403
) ;
396
404
return { } ;
397
405
} ,
@@ -475,13 +483,12 @@ test('browser plugin integration test withRPCReactor - failure', async t => {
475
483
} ,
476
484
} ;
477
485
478
- const expectedActions = [ { type : '@@redux/INIT' } ] ;
486
+ const expectedActions = [ { type : initActionPattern } ] ;
479
487
const store = createStore (
480
488
( state , action ) => {
481
- t . deepLooseEqual (
482
- action ,
483
- expectedActions . shift ( ) ,
484
- 'dispatches expected action'
489
+ t . ok (
490
+ expectedActions . shift ( ) . type . test ( action . type ) ,
491
+ 'dispatches expected action type'
485
492
) ;
486
493
return { } ;
487
494
} ,
@@ -581,13 +588,12 @@ test('browser plugin integration test withRPCReactor - failure 2', async t => {
581
588
) ;
582
589
} ;
583
590
584
- const expectedActions = [ { type : '@@redux/INIT' } ] ;
591
+ const expectedActions = [ { type : initActionPattern } ] ;
585
592
const store = createStore (
586
593
( state , action ) => {
587
- t . deepLooseEqual (
588
- action ,
589
- expectedActions . shift ( ) ,
590
- 'dispatches expected action'
594
+ t . ok (
595
+ expectedActions . shift ( ) . type . test ( action . type ) ,
596
+ 'dispatches expected action type'
591
597
) ;
592
598
return action . payload ;
593
599
} ,
0 commit comments