import { ReportingCore } from '../..' ; import { createMockConfig , createMockConfigSchema , createMockLevelLogger , createMockReportingCore , } from '../../test_helpers' ; import { getConditionalHeaders } from '.' ; import { getCustomLogo } from './get_custom_logo' ; let mockReportingPlugin ; const logger = createMockLevelLogger ( ) ; beforeEach ( async ( ) => { mockReportingPlugin = await createMockReportingCore ( createMockConfigSchema ( ) ) ; } ) ; test ( `gets logo from uiSettings` , async ( ) => { const permittedHeaders = { foo : 'bar' , baz : 'quix' , } ; const mockGet = jest . fn ( ) ; mockGet . mockImplementationOnce ( ( ... args ) => { if ( args [ 0 ] === 'xpackReporting:customPdfLogo' ) { return 'purple pony' ; } throw new Error ( 'wrong caller args!' ) ; } ) ; mockReportingPlugin . getUiSettingsServiceFactory = jest . fn ( ) . mockResolvedValue ( { get : mockGet , } ) ; const conditionalHeaders = getConditionalHeaders ( createMockConfig ( createMockConfigSchema ( ) ) , permittedHeaders ) ; const { logo } = await getCustomLogo ( mockReportingPlugin , conditionalHeaders , 'spaceyMcSpaceIdFace' , logger ) ; expect ( mockGet ) . toBeCalledWith ( 'xpackReporting:customPdfLogo' ) ; expect ( logo ) . toBe ( 'purple pony' ) ; } ) ;