@@ -72,6 +72,70 @@ describe('isActive', function () {
7272 } )
7373 } )
7474
75+ describe ( 'nested routes' , function ( ) {
76+ describe ( 'on the child' , function ( ) {
77+ it ( 'is active for the child and the parent' , function ( done ) {
78+ render ( (
79+ < Router history = { createHistory ( '/parent/child' ) } >
80+ < Route path = "/parent" >
81+ < Route path = "child" />
82+ </ Route >
83+ </ Router >
84+ ) , node , function ( ) {
85+ expect ( this . history . isActive ( '/parent/child' ) ) . toBe ( true )
86+ expect ( this . history . isActive ( '/parent/child' , null , true ) ) . toBe ( true )
87+ expect ( this . history . isActive ( '/parent' ) ) . toBe ( true )
88+ expect ( this . history . isActive ( '/parent' , null , true ) ) . toBe ( false )
89+ done ( )
90+ } )
91+ } )
92+
93+ it ( 'is active with extraneous slashes' , function ( done ) {
94+ render ( (
95+ < Router history = { createHistory ( '/parent/child' ) } >
96+ < Route path = "/parent" >
97+ < Route path = "child" />
98+ </ Route >
99+ </ Router >
100+ ) , node , function ( ) {
101+ expect ( this . history . isActive ( '/parent////child////' ) ) . toBe ( true )
102+ done ( )
103+ } )
104+ } )
105+
106+ it ( 'is not active with missing slashes' , function ( done ) {
107+ render ( (
108+ < Router history = { createHistory ( '/parent/child' ) } >
109+ < Route path = "/parent" >
110+ < Route path = "child" />
111+ </ Route >
112+ </ Router >
113+ ) , node , function ( ) {
114+ expect ( this . history . isActive ( '/parentchild' ) ) . toBe ( false )
115+ done ( )
116+ } )
117+ } )
118+ } )
119+
120+ describe ( 'on the parent' , function ( ) {
121+ it ( 'is active for the parent' , function ( done ) {
122+ render ( (
123+ < Router history = { createHistory ( '/parent' ) } >
124+ < Route path = "/parent" >
125+ < Route path = "child" />
126+ </ Route >
127+ </ Router >
128+ ) , node , function ( ) {
129+ expect ( this . history . isActive ( '/parent/child' ) ) . toBe ( false )
130+ expect ( this . history . isActive ( '/parent/child' , null , true ) ) . toBe ( false )
131+ expect ( this . history . isActive ( '/parent' ) ) . toBe ( true )
132+ expect ( this . history . isActive ( '/parent' , null , true ) ) . toBe ( true )
133+ done ( )
134+ } )
135+ } )
136+ } )
137+ } )
138+
75139 describe ( 'a pathname that matches a parent route, but not the URL directly' , function ( ) {
76140 describe ( 'with no query' , function ( ) {
77141 it ( 'is active' , function ( done ) {
@@ -188,6 +252,96 @@ describe('isActive', function () {
188252 } )
189253 } )
190254 } )
255+
256+ describe ( 'with the index route nested under a pathless route' , function ( ) {
257+ it ( 'is active' , function ( done ) {
258+ render ( (
259+ < Router history = { createHistory ( '/home' ) } >
260+ < Route path = "/home" >
261+ < Route >
262+ < IndexRoute />
263+ </ Route >
264+ </ Route >
265+ </ Router >
266+ ) , node , function ( ) {
267+ expect ( this . history . isActive ( '/home' , null ) ) . toBe ( true )
268+ expect ( this . history . isActive ( '/home' , null , true ) ) . toBe ( true )
269+ done ( )
270+ } )
271+ } )
272+ } )
273+
274+ describe ( 'with a nested index route' , function ( ) {
275+ it ( 'is active' , function ( done ) {
276+ render ( (
277+ < Router history = { createHistory ( '/parent/child' ) } >
278+ < Route path = "/parent" >
279+ < Route path = "child" >
280+ < IndexRoute />
281+ </ Route >
282+ </ Route >
283+ </ Router >
284+ ) , node , function ( ) {
285+ expect ( this . history . isActive ( '/parent/child' , null ) ) . toBe ( true )
286+ expect ( this . history . isActive ( '/parent/child' , null , true ) ) . toBe ( true )
287+ done ( )
288+ } )
289+ } )
290+
291+ it ( 'is active with extraneous slashes' , function ( done ) {
292+ render ( (
293+ < Router history = { createHistory ( '/parent/child' ) } >
294+ < Route path = "/parent" >
295+ < Route path = "child" >
296+ < IndexRoute />
297+ </ Route >
298+ </ Route >
299+ </ Router >
300+ ) , node , function ( ) {
301+ expect ( this . history . isActive ( '/parent///child///' , null ) ) . toBe ( true )
302+ expect ( this . history . isActive ( '/parent///child///' , null , true ) ) . toBe ( true )
303+ done ( )
304+ } )
305+ } )
306+ } )
307+
308+ describe ( 'with a nested index route under a pathless route' , function ( ) {
309+ it ( 'is active' , function ( done ) {
310+ render ( (
311+ < Router history = { createHistory ( '/parent/child' ) } >
312+ < Route path = "/parent" >
313+ < Route path = "child" >
314+ < Route >
315+ < IndexRoute />
316+ </ Route >
317+ </ Route >
318+ </ Route >
319+ </ Router >
320+ ) , node , function ( ) {
321+ expect ( this . history . isActive ( '/parent/child' , null ) ) . toBe ( true )
322+ expect ( this . history . isActive ( '/parent/child' , null , true ) ) . toBe ( true )
323+ done ( )
324+ } )
325+ } )
326+
327+ it ( 'is active with extraneous slashes' , function ( done ) {
328+ render ( (
329+ < Router history = { createHistory ( '/parent/child' ) } >
330+ < Route path = "/parent" >
331+ < Route path = "child" >
332+ < Route >
333+ < IndexRoute />
334+ </ Route >
335+ </ Route >
336+ </ Route >
337+ </ Router >
338+ ) , node , function ( ) {
339+ expect ( this . history . isActive ( '/parent///child///' , null ) ) . toBe ( true )
340+ expect ( this . history . isActive ( '/parent///child///' , null , true ) ) . toBe ( true )
341+ done ( )
342+ } )
343+ } )
344+ } )
191345 } )
192346
193347 describe ( 'a pathname that matches only the beginning of the URL' , function ( ) {
0 commit comments