@@ -114,15 +114,43 @@ describe('isActive', function () {
114
114
} )
115
115
} )
116
116
117
- it ( 'is active with extraneous slashes ' , function ( done ) {
117
+ it ( 'is active with trailing slash on pattern ' , function ( done ) {
118
118
render ( (
119
119
< Router history = { createHistory ( '/parent/child' ) } >
120
120
< Route path = "/parent" >
121
121
< Route path = "child" />
122
122
</ Route >
123
123
</ Router >
124
124
) , node , function ( ) {
125
- expect ( this . router . isActive ( '/parent////child////' ) ) . toBe ( true )
125
+ expect ( this . router . isActive ( '/parent/child/' ) ) . toBe ( true )
126
+ done ( )
127
+ } )
128
+ } )
129
+
130
+ it ( 'is active with trailing slash on location' , function ( done ) {
131
+ render ( (
132
+ < Router history = { createHistory ( '/parent/child/' ) } >
133
+ < Route path = "/parent" >
134
+ < Route path = "child" />
135
+ </ Route >
136
+ </ Router >
137
+ ) , node , function ( ) {
138
+ expect ( this . router . isActive ( '/parent/child' ) ) . toBe ( true )
139
+ expect ( this . router . isActive ( '/parent/child/' ) ) . toBe ( true )
140
+ done ( )
141
+ } )
142
+ } )
143
+
144
+ it ( 'is not active with extraneous slashes' , function ( done ) {
145
+ render ( (
146
+ < Router history = { createHistory ( '/parent/child' ) } >
147
+ < Route path = "/parent" >
148
+ < Route path = "child" />
149
+ </ Route >
150
+ </ Router >
151
+ ) , node , function ( ) {
152
+ expect ( this . router . isActive ( '/parent//child' ) ) . toBe ( false )
153
+ expect ( this . router . isActive ( '/parent/child//' ) ) . toBe ( false )
126
154
done ( )
127
155
} )
128
156
} )
@@ -336,7 +364,41 @@ describe('isActive', function () {
336
364
} )
337
365
} )
338
366
339
- it ( 'is active with extraneous slashes' , function ( done ) {
367
+ it ( 'is active with trailing slash on pattern' , function ( done ) {
368
+ render ( (
369
+ < Router history = { createHistory ( '/parent/child' ) } >
370
+ < Route path = "/parent" >
371
+ < Route path = "child" >
372
+ < IndexRoute />
373
+ </ Route >
374
+ </ Route >
375
+ </ Router >
376
+ ) , node , function ( ) {
377
+ expect ( this . router . isActive ( '/parent/child/' ) ) . toBe ( true )
378
+ expect ( this . router . isActive ( '/parent/child/' , true ) ) . toBe ( true )
379
+ done ( )
380
+ } )
381
+ } )
382
+
383
+ it ( 'is active with trailing slash on location' , function ( done ) {
384
+ render ( (
385
+ < Router history = { createHistory ( '/parent/child/' ) } >
386
+ < Route path = "/parent" >
387
+ < Route path = "child" >
388
+ < IndexRoute />
389
+ </ Route >
390
+ </ Route >
391
+ </ Router >
392
+ ) , node , function ( ) {
393
+ expect ( this . router . isActive ( '/parent/child' ) ) . toBe ( true )
394
+ expect ( this . router . isActive ( '/parent/child' , true ) ) . toBe ( true )
395
+ expect ( this . router . isActive ( '/parent/child/' ) ) . toBe ( true )
396
+ expect ( this . router . isActive ( '/parent/child/' , true ) ) . toBe ( true )
397
+ done ( )
398
+ } )
399
+ } )
400
+
401
+ it ( 'is not active with extraneous slashes' , function ( done ) {
340
402
render ( (
341
403
< Router history = { createHistory ( '/parent/child' ) } >
342
404
< Route path = "/parent" >
@@ -346,8 +408,10 @@ describe('isActive', function () {
346
408
</ Route >
347
409
</ Router >
348
410
) , node , function ( ) {
349
- expect ( this . router . isActive ( '/parent///child///' ) ) . toBe ( true )
350
- expect ( this . router . isActive ( '/parent///child///' , true ) ) . toBe ( true )
411
+ expect ( this . router . isActive ( '/parent//child' ) ) . toBe ( false )
412
+ expect ( this . router . isActive ( '/parent/child//' ) ) . toBe ( false )
413
+ expect ( this . router . isActive ( '/parent//child' , true ) ) . toBe ( false )
414
+ expect ( this . router . isActive ( '/parent/child//' , true ) ) . toBe ( false )
351
415
done ( )
352
416
} )
353
417
} )
@@ -372,7 +436,45 @@ describe('isActive', function () {
372
436
} )
373
437
} )
374
438
375
- it ( 'is active with extraneous slashes' , function ( done ) {
439
+ it ( 'is active with trailing slash on pattern' , function ( done ) {
440
+ render ( (
441
+ < Router history = { createHistory ( '/parent/child' ) } >
442
+ < Route path = "/parent" >
443
+ < Route path = "child" >
444
+ < Route >
445
+ < IndexRoute />
446
+ </ Route >
447
+ </ Route >
448
+ </ Route >
449
+ </ Router >
450
+ ) , node , function ( ) {
451
+ expect ( this . router . isActive ( '/parent/child/' ) ) . toBe ( true )
452
+ expect ( this . router . isActive ( '/parent/child/' , true ) ) . toBe ( true )
453
+ done ( )
454
+ } )
455
+ } )
456
+
457
+ it ( 'is active with trailing slash on location' , function ( done ) {
458
+ render ( (
459
+ < Router history = { createHistory ( '/parent/child/' ) } >
460
+ < Route path = "/parent" >
461
+ < Route path = "child" >
462
+ < Route >
463
+ < IndexRoute />
464
+ </ Route >
465
+ </ Route >
466
+ </ Route >
467
+ </ Router >
468
+ ) , node , function ( ) {
469
+ expect ( this . router . isActive ( '/parent/child' ) ) . toBe ( true )
470
+ expect ( this . router . isActive ( '/parent/child' , true ) ) . toBe ( true )
471
+ expect ( this . router . isActive ( '/parent/child/' ) ) . toBe ( true )
472
+ expect ( this . router . isActive ( '/parent/child/' , true ) ) . toBe ( true )
473
+ done ( )
474
+ } )
475
+ } )
476
+
477
+ it ( 'is not active with extraneous slashes' , function ( done ) {
376
478
render ( (
377
479
< Router history = { createHistory ( '/parent/child' ) } >
378
480
< Route path = "/parent" >
@@ -384,8 +486,10 @@ describe('isActive', function () {
384
486
</ Route >
385
487
</ Router >
386
488
) , node , function ( ) {
387
- expect ( this . router . isActive ( '/parent///child///' ) ) . toBe ( true )
388
- expect ( this . router . isActive ( '/parent///child///' , true ) ) . toBe ( true )
489
+ expect ( this . router . isActive ( '/parent//child' ) ) . toBe ( false )
490
+ expect ( this . router . isActive ( '/parent/child//' ) ) . toBe ( false )
491
+ expect ( this . router . isActive ( '/parent//child' , true ) ) . toBe ( false )
492
+ expect ( this . router . isActive ( '/parent/child//' , true ) ) . toBe ( false )
389
493
done ( )
390
494
} )
391
495
} )
0 commit comments