@@ -25,10 +25,41 @@ const MENU_STATE = {
2525 id : 'some menu'
2626} ;
2727const EXPLORE_SECTIONS_DEFINITIONS = [
28+ { id : 'definition1' } ,
29+ {
30+ id : 'definition2' ,
31+ nestedSections : [
32+ { id : 'nested_definition1' } ,
33+ { id : 'nested_definition2' }
34+ ]
35+ } ,
36+ { id : 'definition3' } ,
37+ ] ;
38+
39+ const ALL_FLAT_MENUS = [
2840 { id : 'definition1' } ,
2941 { id : 'definition2' } ,
3042 { id : 'definition3' } ,
3143] ;
44+ const ALL_NESTED_MENUS = [
45+ {
46+ id : 'definition1' ,
47+ nestedSections : [
48+ { id : 'nested_definition1' } ,
49+ ]
50+ } , {
51+ id : 'definition2' ,
52+ nestedSections : [
53+ { id : 'nested_definition2' } ,
54+ ]
55+ } , {
56+ id : 'definition3' ,
57+ nestedSections : [
58+ { id : 'nested_definition3' } ,
59+ ]
60+ }
61+ ] ;
62+ const NO_MENUS = [ ] ;
3263
3364describe ( 'MenuResolver' , ( ) => {
3465 let resolver : MenuResolver ;
@@ -130,11 +161,80 @@ describe('MenuResolver', () => {
130161 expect ( menuService . addSection ) . toHaveBeenCalledWith ( MenuID . PUBLIC , jasmine . objectContaining ( {
131162 id : 'explore_definition2' , visible : true ,
132163 } ) ) ;
164+ expect ( menuService . addSection ) . toHaveBeenCalledWith ( MenuID . PUBLIC , jasmine . objectContaining ( {
165+ id : 'explore_nested_definition2' ,
166+ parentID : 'explore_definition2' ,
167+ active : false ,
168+ visible : true
169+ } ) ) ;
133170 expect ( menuService . addSection ) . toHaveBeenCalledWith ( MenuID . PUBLIC , jasmine . objectContaining ( {
134171 id : 'explore_definition3' , visible : true ,
135172 } ) ) ;
136173 } ) ;
137174 } ) ;
175+
176+ describe ( 'handle menus' , ( ) => {
177+ it ( 'should show all flat menus' , ( ) => {
178+ sectionsService . findVisibleSections . and . returnValue (
179+ createSuccessfulRemoteDataObject$ ( createPaginatedList ( ALL_FLAT_MENUS ) )
180+ ) ;
181+ resolver . createPublicMenu$ ( ) . subscribe ( ) ;
182+ expect ( menuService . addSection ) . toHaveBeenCalledWith ( MenuID . PUBLIC , jasmine . objectContaining ( {
183+ id : 'explore_definition1' , visible : true ,
184+ } ) ) ;
185+ expect ( menuService . addSection ) . toHaveBeenCalledWith ( MenuID . PUBLIC , jasmine . objectContaining ( {
186+ id : 'explore_definition2' , visible : true ,
187+ } ) ) ;
188+ expect ( menuService . addSection ) . toHaveBeenCalledWith ( MenuID . PUBLIC , jasmine . objectContaining ( {
189+ id : 'explore_definition3' , visible : true ,
190+ } ) ) ;
191+ } ) ;
192+
193+ it ( 'should show all nested menus' , ( ) => {
194+ sectionsService . findVisibleSections . and . returnValue (
195+ createSuccessfulRemoteDataObject$ ( createPaginatedList ( ALL_NESTED_MENUS ) )
196+ ) ;
197+ resolver . createPublicMenu$ ( ) . subscribe ( ) ;
198+ expect ( menuService . addSection ) . toHaveBeenCalledWith (
199+ MenuID . PUBLIC ,
200+ jasmine . objectContaining ( {
201+ id : 'explore_nested_definition1' ,
202+ parentID : 'explore_definition1' ,
203+ active : false ,
204+ visible : true
205+ } )
206+ ) ;
207+ expect ( menuService . addSection ) . toHaveBeenCalledWith (
208+ MenuID . PUBLIC ,
209+ jasmine . objectContaining ( {
210+ id : 'explore_nested_definition2' ,
211+ parentID : 'explore_definition2' ,
212+ active : false ,
213+ visible : true
214+ } )
215+ ) ;
216+ expect ( menuService . addSection ) . toHaveBeenCalledWith (
217+ MenuID . PUBLIC ,
218+ jasmine . objectContaining ( {
219+ id : 'explore_nested_definition3' ,
220+ parentID : 'explore_definition3' ,
221+ active : false ,
222+ visible : true
223+ } )
224+ ) ;
225+ } ) ;
226+
227+ it ( 'should show no menus' , ( ) => {
228+ sectionsService . findVisibleSections . and . returnValue (
229+ createSuccessfulRemoteDataObject$ ( createPaginatedList ( NO_MENUS ) )
230+ ) ;
231+ resolver . createPublicMenu$ ( ) . subscribe ( ) ;
232+ expect ( menuService . addSection ) . toHaveBeenCalledWith (
233+ MenuID . PUBLIC ,
234+ jasmine . objectContaining ( { } )
235+ ) ;
236+ } ) ;
237+ } ) ;
138238 } ) ;
139239
140240 describe ( 'createAdminMenu$' , ( ) => {
0 commit comments