import { httpServiceMock , HttpSetupMock } from '../../http/http_service.mock' ; import { CapabilitiesService } from './capabilities_service' ; const mockedCapabilities = { catalogue : { } , management : { } , navLinks : { app1 : true , app2 : false , legacyApp1 : true , legacyApp2 : false , } , foo : { feature : true } , bar : { feature : true } , } ; describe ( '#start' , ( ) => { let http ; beforeEach ( ( ) => { http = httpServiceMock . createStartContract ( ) ; http . post . mockReturnValue ( Promise . resolve ( mockedCapabilities ) ) ; } ) ; it ( 'only returns capabilities for given appIds' , async ( ) => { const service = new CapabilitiesService ( ) ; const { capabilities } = await service . start ( { http , appIds : [ 'app1' , 'app2' , 'legacyApp1' , 'legacyApp2' ] , } ) ; expect ( ( ) => ( capabilities . foo = 'foo' ) ) . toThrowError ( ) ; } ) ; it ( 'does not allow Capabilities to be modified' , async ( ) => { const service = new CapabilitiesService ( ) ; const { capabilities } = await service . start ( { http , appIds : [ 'app1' , 'app2' , 'legacyApp1' , 'legacyApp2' ] , } ) ; expect ( ( ) => ( capabilities . foo = 'foo' ) ) . toThrowError ( ) ; } ) ; } ) ;