import { coreMock , loggingSystemMock } from 'src/core/server/mocks' ; import { SPACES_USAGE_STATS_TYPE } from './constants' ; import { UsageStatsClient } from './usage_stats_client' ; import { UsageStatsService } from './usage_stats_service' ; describe ( 'UsageStatsService' , ( ) => { const mockLogger = loggingSystemMock . createLogger ( ) ; describe ( '#setup' , ( ) => { const setup = async ( ) => { const core = coreMock . createSetup ( ) ; const usageStatsService = await new UsageStatsService ( mockLogger ) . setup ( core ) ; return { core , usageStatsService } ; } ; it ( 'creates internal repository' , async ( ) => { const { core } = await setup ( ) ; const [ { savedObjects } ] = await core . getStartServices ( ) ; expect ( savedObjects . createInternalRepository ) . toHaveBeenCalledTimes ( 1 ) ; expect ( savedObjects . createInternalRepository ) . toHaveBeenCalledWith ( [ SPACES_USAGE_STATS_TYPE ] ) ; } ) ; describe ( '#getClient' , ( ) => { it ( 'returns client' , async ( ) => { const { usageStatsService } = await setup ( ) ; const usageStatsClient = usageStatsService . getClient ( ) ; expect ( usageStatsClient ) . toBeInstanceOf ( UsageStatsClient ) ; } ) ; } ) ; } ) ; } ) ;