@@ -359,7 +359,11 @@ describe('when multiple top-level children are provided', () => {
359
359
} ;
360
360
361
361
describe ( 'flattenNavigationIndex' , ( ) => {
362
- it ( 'prefers modules' , ( ) => {
362
+ it ( 'prefers the root child with the same url path prefix' , ( ) => {
363
+ Object . defineProperty ( window , 'location' , {
364
+ value : { href : 'http://localhost/documentation/b/b42' } ,
365
+ } ) ;
366
+
363
367
// use first root node if only one is provided
364
368
let flattenedIndex = flattenNavigationIndex ( { swift : [ a ] } ) ;
365
369
expect ( flattenedIndex . swift . length ) . toBe ( 1 ) ;
@@ -368,7 +372,7 @@ describe('when multiple top-level children are provided', () => {
368
372
expect ( flattenedIndex . swift . length ) . toBe ( 1 ) ;
369
373
expect ( flattenedIndex . swift [ 0 ] . title ) . toBe ( b . children [ 0 ] . title ) ;
370
374
371
- // prefer "module" root when multiple top-level nodes are provided
375
+ // prefers root node with same url path prefix when multiple are provided
372
376
flattenedIndex = flattenNavigationIndex ( { swift : [ a , b ] } ) ;
373
377
expect ( flattenedIndex . swift . length ) . toBe ( 1 ) ;
374
378
expect ( flattenedIndex . swift [ 0 ] . title ) . toBe ( b . children [ 0 ] . title ) ;
@@ -388,14 +392,18 @@ describe('when multiple top-level children are provided', () => {
388
392
} ) ;
389
393
390
394
describe ( 'extractTechnologyProps' , ( ) => {
391
- it ( 'prefers modules' , ( ) => {
395
+ it ( 'prefers the root child with the same url path prefix' , ( ) => {
396
+ Object . defineProperty ( window , 'location' , {
397
+ value : { href : 'http://localhost/documentation/b/b42' } ,
398
+ } ) ;
399
+
392
400
// use first root node if only one is provided
393
401
let props = extractTechnologyProps ( { swift : [ a ] } ) ;
394
402
expect ( props . swift . technology ) . toBe ( a . title ) ;
395
403
props = extractTechnologyProps ( { swift : [ b ] } ) ;
396
404
expect ( props . swift . technology ) . toBe ( b . title ) ;
397
405
398
- // prefer "module" root when multiple top-level nodes are provided
406
+ // prefers root node with same url path prefix when multiple are provided
399
407
props = extractTechnologyProps ( { swift : [ a , b ] } ) ;
400
408
expect ( props . swift . technology ) . toBe ( b . title ) ;
401
409
0 commit comments