@@ -38,7 +38,8 @@ describe('MenuProviderService', () => {
3838 const router = {
3939 events : observableOf ( new ResolveEnd ( 1 , 'test-url' , 'test-url-after-redirect' , {
4040 url : 'test-url' ,
41- root : { url : [ new UrlSegment ( 'test-url' , { } ) ] , data : { }
41+ root : {
42+ url : [ new UrlSegment ( 'test-url' , { } ) ] , data : { }
4243 } ,
4344 data : { }
4445 } as any ) )
@@ -61,25 +62,27 @@ describe('MenuProviderService', () => {
6162
6263
6364 const persistentProvider1 = new TestMenuProvider ( MenuID . PUBLIC , true , 'provider1' , 0 , undefined , undefined , false , [ section ] ) ;
64- const persistentProvider2 = new TestMenuProvider ( MenuID . PUBLIC , true , 'provider2' , 1 , undefined , 'provider1' , false , [ section ] ) ;
65+ const persistentProvider2 = new TestMenuProvider ( MenuID . PUBLIC , true , 'provider2' , 1 , undefined , 'provider1' , false , [ section , section ] ) ;
6566 const nonPersistentProvider3 = new TestMenuProvider ( MenuID . PUBLIC , false , 'provider3' , 2 , undefined , undefined , false , [ section ] ) ;
6667 const nonPersistentProvider4 = new TestMenuProvider ( MenuID . PUBLIC , false , 'provider4' , 3 , undefined , 'provider3' , false , [ section ] ) ;
6768 const nonPersistentProvider5WithRoutes = new TestMenuProvider ( MenuID . PUBLIC , false , 'provider4' , 3 , [ MenuRoute . SIMPLE_COMMUNITY_PAGE , MenuRoute . SIMPLE_COLLECTION_PAGE , ] , undefined , false , [ section ] ) ;
6869
6970 const listOfProvider = [ persistentProvider1 , persistentProvider2 , nonPersistentProvider3 , nonPersistentProvider4 , nonPersistentProvider5WithRoutes ] ;
7071
7172 const expectedSection1 = generateAddedSection ( persistentProvider1 , section ) ;
72- const expectedSection2 = generateAddedSection ( persistentProvider2 , section ) ;
73+ const expectedSection21 = generateAddedSection ( persistentProvider2 , section ) ;
74+ const expectedSection22 = generateAddedSection ( persistentProvider2 , section , 1 ) ;
7375 const expectedSection3 = generateAddedSection ( nonPersistentProvider3 , section ) ;
7476 const expectedSection4 = generateAddedSection ( nonPersistentProvider4 , section ) ;
7577 const expectedSection5 = generateAddedSection ( nonPersistentProvider5WithRoutes , section ) ;
7678
77- function generateAddedSection ( provider , sectionToAdd ) {
79+ function generateAddedSection ( provider , sectionToAdd , index = 0 ) {
7880 return {
7981 ...sectionToAdd ,
80- id : sectionToAdd . id ?? `${ provider . menuProviderId } ` ,
82+ id : sectionToAdd . id ?? `${ provider . menuProviderId } _ ${ index } ` ,
8183 parentID : sectionToAdd . parentID ?? provider . parentID ,
8284 index : sectionToAdd . index ?? provider . index ,
85+ active : false ,
8386 shouldPersistOnRouteChange : sectionToAdd . shouldPersistOnRouteChange ?? provider . shouldPersistOnRouteChange ,
8487 alwaysRenderExpandable : sectionToAdd . alwaysRenderExpandable ?? provider . alwaysRenderExpandable ,
8588 } ;
@@ -106,7 +109,8 @@ describe('MenuProviderService', () => {
106109 menuProviderService . initPersistentMenus ( ) ;
107110
108111 expect ( menuService . addSection ) . toHaveBeenCalledWith ( persistentProvider1 . menuID , expectedSection1 ) ;
109- expect ( menuService . addSection ) . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection2 ) ;
112+ expect ( menuService . addSection ) . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection21 ) ;
113+ expect ( menuService . addSection ) . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection22 ) ;
110114 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( nonPersistentProvider3 . menuID , expectedSection3 ) ;
111115 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( nonPersistentProvider4 . menuID , expectedSection4 ) ;
112116 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( nonPersistentProvider5WithRoutes . menuID , expectedSection5 ) ;
@@ -115,7 +119,7 @@ describe('MenuProviderService', () => {
115119
116120 describe ( 'resolveRouteMenus with no matching path specific providers' , ( ) => {
117121 it ( 'should remove the current non persistent menus and add the general non persistent menus' , ( ) => {
118- const route = { data :{ } } ;
122+ const route = { data : { } } ;
119123 const state = { url : 'test-url' } ;
120124 menuProviderService . resolveRouteMenus ( route as any , state as any ) . subscribe ( ) ;
121125
@@ -124,7 +128,8 @@ describe('MenuProviderService', () => {
124128 expect ( menuService . removeSection ) . toHaveBeenCalledWith ( MenuID . DSO_EDIT , sectionToBeRemoved . id ) ;
125129
126130 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider1 . menuID , expectedSection1 ) ;
127- expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection2 ) ;
131+ expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection21 ) ;
132+ expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection22 ) ;
128133 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider3 . menuID , expectedSection3 ) ;
129134 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider4 . menuID , expectedSection4 ) ;
130135 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( nonPersistentProvider5WithRoutes . menuID , expectedSection5 ) ;
@@ -133,7 +138,7 @@ describe('MenuProviderService', () => {
133138
134139 describe ( 'resolveRouteMenus with a matching path specific provider' , ( ) => {
135140 it ( 'should remove the current non persistent menus and add the general non persistent menus' , ( ) => {
136- const route = { data :{ menuRoute : MenuRoute . SIMPLE_COMMUNITY_PAGE } } ;
141+ const route = { data : { menuRoute : MenuRoute . SIMPLE_COMMUNITY_PAGE } } ;
137142 const state = { url : `xxxx/${ COMMUNITY_MODULE_PATH } /xxxxxx` } ;
138143 menuProviderService . resolveRouteMenus ( route as any , state as any ) . subscribe ( ) ;
139144
@@ -142,7 +147,8 @@ describe('MenuProviderService', () => {
142147 expect ( menuService . removeSection ) . toHaveBeenCalledWith ( MenuID . DSO_EDIT , sectionToBeRemoved . id ) ;
143148
144149 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider1 . menuID , expectedSection1 ) ;
145- expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection2 ) ;
150+ expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection21 ) ;
151+ expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection22 ) ;
146152 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider3 . menuID , expectedSection3 ) ;
147153 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider4 . menuID , expectedSection4 ) ;
148154 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider5WithRoutes . menuID , expectedSection5 ) ;
@@ -158,7 +164,8 @@ describe('MenuProviderService', () => {
158164 expect ( menuService . removeSection ) . toHaveBeenCalledWith ( MenuID . DSO_EDIT , sectionToBeRemoved . id ) ;
159165
160166 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider1 . menuID , expectedSection1 ) ;
161- expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection2 ) ;
167+ expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection21 ) ;
168+ expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( persistentProvider2 . menuID , expectedSection22 ) ;
162169 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider3 . menuID , expectedSection3 ) ;
163170 expect ( menuService . addSection ) . toHaveBeenCalledWith ( nonPersistentProvider4 . menuID , expectedSection4 ) ;
164171 expect ( menuService . addSection ) . not . toHaveBeenCalledWith ( nonPersistentProvider5WithRoutes . menuID , expectedSection5 ) ;
0 commit comments