88
99import { TestBed } from '@angular/core/testing' ;
1010
11+ import {
12+ APP_CONFIG ,
13+ AppConfig ,
14+ } from '../../../../config/app-config.interface' ;
1115import { BrowseService } from '../../../core/browse/browse.service' ;
1216import { ObjectCacheService } from '../../../core/cache/object-cache.service' ;
1317import { BrowseDefinition } from '../../../core/shared/browse-definition.model' ;
@@ -30,7 +34,7 @@ describe('BrowseMenuProvider', () => {
3034 icon : 'globe' ,
3135 } ;
3236
33- const expectedSubSections : PartialMenuSection [ ] = [
37+ const expectedSubSections : ( enableMapLink : boolean ) => PartialMenuSection [ ] = ( enableMapLink ) => [
3438 {
3539 visible : true ,
3640 model : {
@@ -47,6 +51,14 @@ describe('BrowseMenuProvider', () => {
4751 link : '/browse/subject' ,
4852 } ,
4953 } ,
54+ {
55+ visible : enableMapLink ,
56+ model : {
57+ type : MenuItemType . LINK ,
58+ text : `menu.section.browse_global_geospatial_map` ,
59+ link : `/browse/map` ,
60+ } ,
61+ } ,
5062 ] ;
5163
5264
@@ -66,6 +78,7 @@ describe('BrowseMenuProvider', () => {
6678 BrowseMenuProvider ,
6779 { provide : BrowseService , useValue : browseServiceStub } ,
6880 { provide : ObjectCacheService , useValue : getMockObjectCacheService ( ) } ,
81+ { provide : APP_CONFIG , useValue : { geospatialMapViewer : { enableBrowseMap : true } } as AppConfig } ,
6982 ] ,
7083 } ) ;
7184 provider = TestBed . inject ( BrowseMenuProvider ) ;
@@ -84,7 +97,15 @@ describe('BrowseMenuProvider', () => {
8497
8598 it ( 'getSubSections should return expected menu sections' , ( done ) => {
8699 provider . getSubSections ( ) . subscribe ( ( sections ) => {
87- expect ( sections ) . toEqual ( expectedSubSections ) ;
100+ expect ( sections ) . toEqual ( expectedSubSections ( true ) ) ;
101+ done ( ) ;
102+ } ) ;
103+ } ) ;
104+
105+ it ( 'getSubSections should return expected menu sections' , ( done ) => {
106+ TestBed . inject ( APP_CONFIG ) . geospatialMapViewer . enableBrowseMap = false ;
107+ provider . getSubSections ( ) . subscribe ( ( sections ) => {
108+ expect ( sections ) . toEqual ( expectedSubSections ( false ) ) ;
88109 done ( ) ;
89110 } ) ;
90111 } ) ;
0 commit comments