import { opensearchClientMock } from './mocks' ; describe ( 'Mocked client' , ( ) => { let client ; const expectMocked = ( fn ) => { expect ( fn ) . toBeDefined ( ) ; expect ( fn . mockReturnValue ) . toEqual ( expect . any ( Function ) ) ; } ; beforeEach ( ( ) => { client = opensearchClientMock . createInternalClient ( ) ; } ) ; it ( '`transport.request` should be mocked' , ( ) => { expectMocked ( client . transport . request ) ; } ) ; it ( 'root level API methods should be mocked' , ( ) => { expectMocked ( client . bulk ) ; expectMocked ( client . search ) ; } ) ; it ( 'nested level API methods should be mocked' , ( ) => { expectMocked ( client . asyncSearch . get ) ; expectMocked ( client . nodes . info ) ; } ) ; it ( '`close` should be mocked' , ( ) => { expectMocked ( client . close ) ; } ) ; it ( 'used EventEmitter functions should be mocked' , ( ) => { expectMocked ( client . on ) ; expectMocked ( client . off ) ; expectMocked ( client . once ) ; } ) ; it ( '`child` should be mocked and return a mocked Client' , ( ) => { expectMocked ( client . child ) ; const child = client . child ( ) ; expect ( child ) . not . toBe ( client ) ; expectMocked ( child . search ) ; } ) ; } ) ;