import supertest from 'supertest' ; import { REPO_ROOT } from '@osd/dev-utils' ; import { HttpService , InternalHttpServiceSetup } from '../../http' ; import { contextServiceMock } from '../../context/context_service.mock' ; import { loggingSystemMock } from '../../logging/logging_system.mock' ; import { Env } from '../../config' ; import { getEnvOptions } from '../../config/mocks' ; import { CapabilitiesService , CapabilitiesSetup } from '..' ; import { createHttpServer } from '../../http/test_utils' ; const coreId = Symbol ( 'core' ) ; const env = Env . createDefault ( REPO_ROOT , getEnvOptions ( ) ) ; describe ( 'CapabilitiesService' , ( ) => { let server ; let httpSetup ; let service ; let serviceSetup ; beforeEach ( async ( ) => { server = createHttpServer ( ) ; httpSetup = await server . setup ( { context : contextServiceMock . createSetupContract ( ) , } ) ; service = new CapabilitiesService ( { coreId , env , logger : loggingSystemMock . create ( ) , configService : { } as any , } ) ; serviceSetup = await service . setup ( { http : httpSetup } ) ; await server . start ( ) ; } ) ; afterEach ( async ( ) => { await server . stop ( ) ; } ) ; describe ( '/api/core/capabilities route' , ( ) => { it ( 'is exposed' , async ( ) => { const result = await supertest ( httpSetup . server . listener ) . post ( '/api/core/capabilities' ) . send ( { applications : [ ] } ) . expect ( 200 ) ; expect ( result . body ) . toMatchInlineSnapshot ( `
              Object {
                "catalogue": Object {},
                "management": Object {},
                "navLinks": Object {},
              }
          ` ) ; } ) ; it ( 'uses the service capabilities providers' , async ( ) => { serviceSetup . registerProvider ( ( ) => ( { catalogue : { something : true , } , } ) ) ; const result = await supertest ( httpSetup . server . listener ) . post ( '/api/core/capabilities' ) . send ( { applications : [ ] } ) . expect ( 200 ) ; expect ( result . body ) . toMatchInlineSnapshot ( `
        Object {
          "catalogue": Object {
            "something": true,
          },
          "management": Object {},
          "navLinks": Object {},
        }
      ` ) ; } ) ; } ) ; } ) ;