import { act , renderHook } from '@testing-library/react-hooks' ; import { useReadListIndex } from '@kbn/securitysolution-list-hooks' ; import * as Api from '@kbn/securitysolution-list-api' ; import { httpServiceMock } from '../../../../../../src/core/public/mocks' ; import { getAcknowledgeSchemaResponseMock } from '../../../common/schemas/response/acknowledge_schema.mock' ; jest . mock ( '@kbn/securitysolution-list-api' ) ; describe ( 'useReadListIndex' , ( ) => { let httpMock ; beforeEach ( ( ) => { httpMock = httpServiceMock . createStartContract ( ) ; ( Api . readListIndex as jest . Mock ) . mockResolvedValue ( getAcknowledgeSchemaResponseMock ( ) ) ; } ) ; it ( 'invokes Api.readListIndex' , async ( ) => { const { result , waitForNextUpdate } = renderHook ( ( ) => useReadListIndex ( ) ) ; act ( ( ) => { result . current . start ( { http : httpMock } ) ; } ) ; await waitForNextUpdate ( ) ; expect ( Api . readListIndex ) . toHaveBeenCalledWith ( expect . objectContaining ( { http : httpMock } ) ) ; } ) ; } ) ;