import { getApmTelemetryMapping , mergeApmTelemetryMapping , } from './apm_telemetry' ; expect . addSnapshotSerializer ( { print : ( contents ) => { return JSON . stringify ( contents , null , 2 ) ; } , test : ( ) => true , } ) ; describe ( 'APM telemetry helpers' , ( ) => { describe ( 'getApmTelemetry' , ( ) => { it ( 'generates a JSON object with the telemetry mapping' , ( ) => { expect ( { properties : { stack_stats : { properties : { kibana : { properties : { plugins : { properties : { apm : getApmTelemetryMapping ( ) , } , } , } , } , } , } , } , } ) . toMatchSnapshot ( ) ; } ) ; } ) ; describe ( 'mergeApmTelemetryMapping' , ( ) => { describe ( 'with an invalid mapping' , ( ) => { it ( 'throws an error' , ( ) => { expect ( ( ) => mergeApmTelemetryMapping ( { } ) ) . toThrowError ( ) ; } ) ; } ) ; describe ( 'with a valid mapping' , ( ) => { it ( 'merges the mapping' , ( ) => { const validTelemetryMapping = { mappings : { properties : { stack_stats : { properties : { kibana : { properties : { plugins : { properties : { apm : getApmTelemetryMapping ( ) , } , } , } , } , } , } , } , } , } ; expect ( mergeApmTelemetryMapping ( validTelemetryMapping ) ?. mappings . properties . stack_stats . properties . kibana . properties . plugins . properties . apm ) . toEqual ( getApmTelemetryMapping ( ) ) ; } ) ; } ) ; } ) ; } ) ;