import { usageCountersServiceMock } from 'src/plugins/usage_collection/server/usage_counters/usage_counters_service.mock' ; import { trackLegacyRouteUsage } from './track_legacy_route_usage' ; describe ( 'trackLegacyRouteUsage' , ( ) => { it ( 'should call `usageCounter.incrementCounter`' , ( ) => { const mockUsageCountersSetup = usageCountersServiceMock . createSetupContract ( ) ; const mockUsageCounter = mockUsageCountersSetup . createUsageCounter ( 'test' ) ; trackLegacyRouteUsage ( 'test' , mockUsageCounter ) ; expect ( mockUsageCounter . incrementCounter ) . toHaveBeenCalledWith ( { counterName : `legacyRoute_test` , counterType : 'legacyApiUsage' , incrementBy : 1 , } ) ; } ) ; it ( 'should do nothing if no usage counter is provided' , ( ) => { let err ; try { trackLegacyRouteUsage ( 'test' , undefined ) ; } catch ( e ) { err = e ; } expect ( err ) . toBeUndefined ( ) ; } ) ; } ) ;