@@ -359,7 +359,11 @@ describe('when multiple top-level children are provided', () => {
359359 } ;
360360
361361 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+
363367 // use first root node if only one is provided
364368 let flattenedIndex = flattenNavigationIndex ( { swift : [ a ] } ) ;
365369 expect ( flattenedIndex . swift . length ) . toBe ( 1 ) ;
@@ -368,7 +372,7 @@ describe('when multiple top-level children are provided', () => {
368372 expect ( flattenedIndex . swift . length ) . toBe ( 1 ) ;
369373 expect ( flattenedIndex . swift [ 0 ] . title ) . toBe ( b . children [ 0 ] . title ) ;
370374
371- // prefer "module" root when multiple top-level nodes are provided
375+ // prefers root node with same url path prefix when multiple are provided
372376 flattenedIndex = flattenNavigationIndex ( { swift : [ a , b ] } ) ;
373377 expect ( flattenedIndex . swift . length ) . toBe ( 1 ) ;
374378 expect ( flattenedIndex . swift [ 0 ] . title ) . toBe ( b . children [ 0 ] . title ) ;
@@ -388,14 +392,18 @@ describe('when multiple top-level children are provided', () => {
388392 } ) ;
389393
390394 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+
392400 // use first root node if only one is provided
393401 let props = extractTechnologyProps ( { swift : [ a ] } ) ;
394402 expect ( props . swift . technology ) . toBe ( a . title ) ;
395403 props = extractTechnologyProps ( { swift : [ b ] } ) ;
396404 expect ( props . swift . technology ) . toBe ( b . title ) ;
397405
398- // prefer "module" root when multiple top-level nodes are provided
406+ // prefers root node with same url path prefix when multiple are provided
399407 props = extractTechnologyProps ( { swift : [ a , b ] } ) ;
400408 expect ( props . swift . technology ) . toBe ( b . title ) ;
401409
0 commit comments