import { UsageCollectionSetup } from 'src/plugins/usage_collection/server' ; import { registerAlertsUsageCollector } from './alerts_usage_collector' ; import { taskManagerMock } from '../../../task_manager/server/mocks' ; const taskManagerStart = taskManagerMock . createStart ( ) ; beforeEach ( ( ) => jest . resetAllMocks ( ) ) ; describe ( 'registerAlertsUsageCollector' , ( ) => { let usageCollectionMock ; beforeEach ( ( ) => { usageCollectionMock = { makeUsageCollector : jest . fn ( ) , registerCollector : jest . fn ( ) , } as unknown as jest . Mocked < UsageCollectionSetup > ; } ) ; it ( 'should call registerCollector' , ( ) => { registerAlertsUsageCollector ( usageCollectionMock as UsageCollectionSetup , new Promise ( ( ) => taskManagerStart ) ) ; expect ( usageCollectionMock . registerCollector ) . toHaveBeenCalledTimes ( 1 ) ; } ) ; it ( 'should call makeUsageCollector with type = alerts' , ( ) => { registerAlertsUsageCollector ( usageCollectionMock as UsageCollectionSetup , new Promise ( ( ) => taskManagerStart ) ) ; expect ( usageCollectionMock . makeUsageCollector ) . toHaveBeenCalledTimes ( 1 ) ; expect ( usageCollectionMock . makeUsageCollector . mock . calls [ 0 ] [ 0 ] . type ) . toBe ( 'alerts' ) ; } ) ; } ) ;