import { registerRoutesMock } from './plugin.test.mocks' ; import { coreMock } from '../../../../src/core/server/mocks' ; import { GlobalSearchPlugin } from './plugin' ; describe ( 'GlobalSearchPlugin' , ( ) => { let plugin ; beforeEach ( ( ) => { plugin = new GlobalSearchPlugin ( coreMock . createPluginInitializerContext ( ) ) ; } ) ; it ( 'registers routes during `setup`' , async ( ) => { await plugin . setup ( coreMock . createSetup ( ) ) ; expect ( registerRoutesMock ) . toHaveBeenCalledTimes ( 1 ) ; } ) ; it ( 'registers the globalSearch route handler context' , async ( ) => { const coreSetup = coreMock . createSetup ( ) ; await plugin . setup ( coreSetup ) ; expect ( coreSetup . http . registerRouteHandlerContext ) . toHaveBeenCalledTimes ( 1 ) ; expect ( coreSetup . http . registerRouteHandlerContext ) . toHaveBeenCalledWith ( 'globalSearch' , expect . any ( Function ) ) ; } ) ; } ) ;