@@ -170,7 +170,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
170
170
devToolsStore = store . devToolsStore
171
171
172
172
// Set initial URL before syncing
173
- history . pushState ( null , '/foo' )
173
+ history . push ( '/foo' )
174
174
175
175
unsubscribe = syncReduxAndRouter ( history , store )
176
176
} )
@@ -185,7 +185,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
185
185
currentPath = location . pathname
186
186
} )
187
187
188
- history . pushState ( null , '/bar' )
188
+ history . push ( '/bar' )
189
189
store . dispatch ( pushPath ( '/baz' ) )
190
190
191
191
// By calling reset we expect DevTools to re-play the initial state
@@ -205,9 +205,9 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
205
205
} )
206
206
207
207
// DevTools action #2
208
- history . pushState ( null , '/foo2' )
208
+ history . push ( '/foo2' )
209
209
// DevTools action #3
210
- history . pushState ( null , '/foo3' )
210
+ history . push ( '/foo3' )
211
211
212
212
// When we toggle an action, the devtools will revert the action
213
213
// and we therefore expect the history to update to the previous path
@@ -253,52 +253,66 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
253
253
254
254
it ( 'syncs router -> redux' , ( ) => {
255
255
expect ( store ) . toContainRoute ( {
256
- path : '/'
256
+ path : '/' ,
257
+ state : null
257
258
} )
258
259
259
- history . pushState ( null , '/foo' )
260
+ history . push ( '/foo' )
260
261
expect ( store ) . toContainRoute ( {
261
262
path : '/foo' ,
262
263
replace : false ,
263
264
state : null
264
265
} )
265
266
266
- history . pushState ( { bar : 'baz' } , '/foo' )
267
+ history . push ( { state : { bar : 'baz' } , pathname : '/foo' } )
267
268
expect ( store ) . toContainRoute ( {
268
269
path : '/foo' ,
269
270
replace : true ,
270
271
state : { bar : 'baz' }
271
272
} )
272
273
273
- history . replaceState ( null , '/bar' )
274
+ history . replace ( '/bar' )
274
275
expect ( store ) . toContainRoute ( {
275
276
path : '/bar' ,
276
277
replace : true ,
277
278
state : null
278
279
} )
279
280
280
- history . pushState ( null , '/bar' )
281
+ history . push ( '/bar' )
281
282
expect ( store ) . toContainRoute ( {
282
283
path : '/bar' ,
283
284
replace : true ,
284
285
state : null
285
286
} )
286
287
287
- history . pushState ( null , '/bar?query=1' )
288
+ history . push ( '/bar?query=1' )
288
289
expect ( store ) . toContainRoute ( {
289
290
path : '/bar?query=1' ,
290
291
replace : false ,
291
292
state : null
292
293
} )
293
294
294
- history . replaceState ( { bar : 'baz' } , '/bar?query=1' )
295
+ history . push ( '/bar#baz' )
296
+ expect ( store ) . toContainRoute ( {
297
+ path : '/bar#baz' ,
298
+ replace : false ,
299
+ state : null
300
+ } )
301
+
302
+ history . replace ( {
303
+ state : { bar : 'baz' } ,
304
+ pathname : '/bar?query=1'
305
+ } )
295
306
expect ( store ) . toContainRoute ( {
296
307
path : '/bar?query=1' ,
297
308
replace : true ,
298
309
state : { bar : 'baz' }
299
310
} )
300
311
301
- history . pushState ( { bar : 'baz' } , '/bar?query=1#hash=2' )
312
+ history . replace ( {
313
+ state : { bar : 'baz' } ,
314
+ pathname : '/bar?query=1#hash=2'
315
+ } )
302
316
expect ( store ) . toContainRoute ( {
303
317
path : '/bar?query=1#hash=2' ,
304
318
replace : true ,
@@ -310,7 +324,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
310
324
expect ( store ) . toContainRoute ( {
311
325
path : '/' ,
312
326
replace : false ,
313
- state : undefined
327
+ state : null
314
328
} )
315
329
316
330
store . dispatch ( pushPath ( '/foo' ) )
@@ -455,7 +469,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
455
469
} ) )
456
470
const history = createHistory ( )
457
471
syncReduxAndRouter ( history , store , state => state . notRouting )
458
- history . pushState ( null , '/bar' )
472
+ history . push ( '/bar' )
459
473
expect ( store . getState ( ) . notRouting . path ) . toEqual ( '/bar' )
460
474
} )
461
475
@@ -466,9 +480,10 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
466
480
const history = createHistory ( )
467
481
const unsubscribe = syncReduxAndRouter ( history , store )
468
482
469
- history . pushState ( null , '/foo' )
483
+ history . push ( '/foo' )
470
484
expect ( store ) . toContainRoute ( {
471
- path : '/foo'
485
+ path : '/foo' ,
486
+ state : null
472
487
} )
473
488
474
489
store . dispatch ( pushPath ( '/bar' ) )
@@ -478,7 +493,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
478
493
479
494
unsubscribe ( )
480
495
481
- history . pushState ( null , '/foo' )
496
+ history . push ( '/foo' )
482
497
expect ( store ) . toContainRoute ( {
483
498
path : '/bar'
484
499
} )
@@ -523,17 +538,18 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
523
538
const store = createStore ( combineReducers ( {
524
539
routing : routeReducer
525
540
} ) )
526
- const history = useBasename ( createHistory ) ( { basename :'/foobar' } )
541
+ const history = useBasename ( createHistory ) ( { basename : '/foobar' } )
527
542
syncReduxAndRouter ( history , store )
528
543
529
544
store . dispatch ( pushPath ( '/bar' ) )
530
545
expect ( store ) . toContainRoute ( {
531
546
path : '/bar'
532
547
} )
533
548
534
- history . pushState ( undefined , '/baz' )
549
+ history . push ( '/baz' )
535
550
expect ( store ) . toContainRoute ( {
536
- path : '/baz'
551
+ path : '/baz' ,
552
+ state : null
537
553
} )
538
554
} )
539
555
} )
0 commit comments