This repository was archived by the owner on Oct 26, 2018. It is now read-only.
File tree 1 file changed +61
-0
lines changed 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -273,6 +273,67 @@ describe('syncReduxAndRouter', () => {
273
273
} ) ;
274
274
} ) ;
275
275
276
+ it ( 'does not unnecessarily update the store' , ( ) => {
277
+ const { history, store } = createSyncedHistoryAndStore ( ) ;
278
+ const updates = [ ] ;
279
+
280
+ const unsubscribe = store . subscribe ( ( ) => {
281
+ updates . push ( store . getState ( ) )
282
+ } ) ;
283
+
284
+ store . dispatch ( pushPath ( '/foo' ) ) ;
285
+ store . dispatch ( pushPath ( '/foo' ) ) ;
286
+ store . dispatch ( pushPath ( '/foo' , { bar : 'baz' } ) ) ;
287
+ store . dispatch ( replacePath ( '/bar' ) ) ;
288
+ store . dispatch ( replacePath ( '/bar' , { bar : 'foo' } ) ) ;
289
+
290
+ unsubscribe ( ) ;
291
+
292
+ expect ( updates . length ) . toBe ( 5 ) ;
293
+ expect ( updates ) . toEqual ( [
294
+ {
295
+ routing : {
296
+ changeId : 2 ,
297
+ path : '/foo' ,
298
+ state : undefined ,
299
+ replace : false
300
+ }
301
+ } ,
302
+ {
303
+ routing : {
304
+ changeId : 3 ,
305
+ path : '/foo' ,
306
+ state : undefined ,
307
+ replace : false
308
+ }
309
+ } ,
310
+ {
311
+ routing : {
312
+ changeId : 4 ,
313
+ path : '/foo' ,
314
+ state : { bar : 'baz' } ,
315
+ replace : false
316
+ }
317
+ } ,
318
+ {
319
+ routing : {
320
+ changeId : 5 ,
321
+ path : '/bar' ,
322
+ state : undefined ,
323
+ replace : true
324
+ }
325
+ } ,
326
+ {
327
+ routing : {
328
+ changeId : 6 ,
329
+ path : '/bar' ,
330
+ state : { bar : 'foo' } ,
331
+ replace : true
332
+ }
333
+ }
334
+ ] ) ;
335
+ } ) ;
336
+
276
337
it ( 'allows updating the route from within `listenBefore`' , ( ) => {
277
338
const { history, store } = createSyncedHistoryAndStore ( ) ;
278
339
expect ( store . getState ( ) . routing ) . toEqual ( {
You can’t perform that action at this time.
0 commit comments