import { ReportingConfig } from '../../' ; import { createMockConfig , createMockConfigSchema } from '../../test_helpers' ; import { getConditionalHeaders } from './' ; let mockConfig ; beforeEach ( async ( ) => { const reportingConfig = { kibanaServer : { hostname : 'custom-hostname' } } ; const mockSchema = createMockConfigSchema ( reportingConfig ) ; mockConfig = createMockConfig ( mockSchema ) ; } ) ; describe ( 'conditions' , ( ) => { test ( `uses hostname from reporting config if set` , async ( ) => { const permittedHeaders = { foo : 'bar' , baz : 'quix' , } ; const conditionalHeaders = getConditionalHeaders ( mockConfig , permittedHeaders ) ; expect ( conditionalHeaders . conditions . hostname ) . toEqual ( mockConfig . get ( 'kibanaServer' , 'hostname' ) ) ; expect ( conditionalHeaders . conditions . port ) . toEqual ( mockConfig . get ( 'kibanaServer' , 'port' ) ) ; expect ( conditionalHeaders . conditions . protocol ) . toEqual ( mockConfig . get ( 'kibanaServer' , 'protocol' ) ) ; expect ( conditionalHeaders . conditions . basePath ) . toEqual ( mockConfig . kbnConfig . get ( 'server' , 'basePath' ) ) ; } ) ; } ) ; describe ( 'config formatting' , ( ) => { test ( `lowercases kibanaServer.hostname` , async ( ) => { const reportingConfig = { kibanaServer : { hostname : 'GREAT-HOSTNAME' } } ; const mockSchema = createMockConfigSchema ( reportingConfig ) ; mockConfig = createMockConfig ( mockSchema ) ; const conditionalHeaders = getConditionalHeaders ( mockConfig , { } ) ; expect ( conditionalHeaders . conditions . hostname ) . toEqual ( 'great-hostname' ) ; } ) ; } ) ;