1
1
import expect from 'expect'
2
- import React from 'react'
3
2
import { createMemoryHistory } from 'history'
4
- import { createRoutes } from '../RouteUtils'
3
+ import React from 'react'
4
+ import { canUseMembrane } from '../deprecateObjectProperties'
5
+ import IndexRoute from '../IndexRoute'
5
6
import matchRoutes from '../matchRoutes'
6
7
import Route from '../Route'
7
- import IndexRoute from '../IndexRoute '
8
+ import { createRoutes } from '../RouteUtils '
8
9
import shouldWarn from './shouldWarn'
9
10
10
11
describe ( 'matchRoutes' , function ( ) {
@@ -330,10 +331,16 @@ describe('matchRoutes', function () {
330
331
] )
331
332
expect ( match . params ) . toEqual ( { groupId : 'foo' , userId : '5' } )
332
333
333
- expect ( getChildRoutes . calls [ 0 ] . arguments [ 0 ] . params ) . toEqual ( {
334
- groupId : 'foo'
335
- } )
336
- expect ( getIndexRoute ) . toNotHaveBeenCalled ( )
334
+ const partialNextState = getChildRoutes . calls [ 0 ] . arguments [ 0 ]
335
+ expect ( partialNextState . params ) . toEqual ( { groupId : 'foo' } )
336
+ expect ( partialNextState . location . pathname ) . toEqual ( '/foo/users/5' )
337
+
338
+ // Only the calls below this point should emit deprecation warnings.
339
+ if ( canUseMembrane ) {
340
+ shouldWarn ( 'deprecated' )
341
+ }
342
+
343
+ expect ( partialNextState . pathname ) . toEqual ( '/foo/users/5' )
337
344
338
345
done ( )
339
346
}
@@ -347,10 +354,16 @@ describe('matchRoutes', function () {
347
354
expect ( match ) . toExist ( )
348
355
expect ( match . routes . map ( r => r . name ) ) . toEqual ( [ 'users' , 'jsx' ] )
349
356
350
- expect ( getIndexRoute . calls [ 0 ] . arguments [ 0 ] . params ) . toEqual ( {
351
- groupId : 'bar'
352
- } )
353
- expect ( getChildRoutes ) . toNotHaveBeenCalled ( )
357
+ const partialNextState = getIndexRoute . calls [ 0 ] . arguments [ 0 ]
358
+ expect ( partialNextState . params ) . toEqual ( { groupId : 'bar' } )
359
+ expect ( partialNextState . location . pathname ) . toEqual ( '/bar/users' )
360
+
361
+ // Only the calls below this point should emit deprecation warnings.
362
+ if ( canUseMembrane ) {
363
+ shouldWarn ( 'deprecated' )
364
+ }
365
+
366
+ expect ( partialNextState . pathname ) . toEqual ( '/bar/users' )
354
367
355
368
done ( )
356
369
}
0 commit comments