Skip to content

Commit

Permalink
add test for #64132 (#64307) (#64639)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
Liza Katz and elasticmachine authored Apr 28, 2020
1 parent f513af2 commit bee297c
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,34 @@ describe('Async search strategy', () => {
});
});

// For bug fixed in https://github.com/elastic/kibana/pull/64155
it('Continues polling if no records are returned on first async request', async () => {
mockSearch
.mockReturnValueOnce(of({ id: 1, total: 0, loaded: 0, is_running: true, is_partial: true }))
.mockReturnValueOnce(
of({ id: 1, total: 2, loaded: 2, is_running: false, is_partial: false })
);

const asyncSearch = asyncSearchStrategyProvider({
core: mockCoreStart,
getSearchStrategy: jest.fn().mockImplementation(() => {
return () => {
return {
search: mockSearch,
};
};
}),
});

expect(mockSearch).toBeCalledTimes(0);

await asyncSearch.search(mockRequest, mockOptions).toPromise();

expect(mockSearch).toBeCalledTimes(2);
expect(mockSearch.mock.calls[0][0]).toEqual(mockRequest);
expect(mockSearch.mock.calls[1][0]).toEqual({ id: 1, serverStrategy: 'foo' });
});

it('only sends the ID and server strategy after the first request', async () => {
mockSearch
.mockReturnValueOnce(of({ id: 1, total: 2, loaded: 1, is_running: true, is_partial: true }))
Expand Down

0 comments on commit bee297c

Please sign in to comment.