mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Add test to useRequest hook to verify ability to cancel poll. (#113947)
This commit is contained in:
parent
244ebca919
commit
35200bea1f
1 changed files with 18 additions and 0 deletions
|
@ -308,6 +308,24 @@ describe('useRequest hook', () => {
|
|||
expect(getSendRequestSpy().callCount).toBe(2);
|
||||
});
|
||||
|
||||
it(`changing pollIntervalMs to undefined cancels the poll`, async () => {
|
||||
const { setupErrorRequest, setErrorResponse, completeRequest, getSendRequestSpy } = helpers;
|
||||
// Send initial request.
|
||||
setupErrorRequest({ pollIntervalMs: REQUEST_TIME });
|
||||
|
||||
// Setting the poll to undefined will cancel subsequent requests.
|
||||
setErrorResponse({ pollIntervalMs: undefined });
|
||||
|
||||
// Complete initial request.
|
||||
await completeRequest();
|
||||
|
||||
// If there were another scheduled poll request, this would complete it.
|
||||
await completeRequest();
|
||||
|
||||
// But because we canceled the poll, we only see 1 request instead of 2.
|
||||
expect(getSendRequestSpy().callCount).toBe(1);
|
||||
});
|
||||
|
||||
it('when the path changes after a request is scheduled, the scheduled request is sent with that path', async () => {
|
||||
const {
|
||||
setupSuccessRequest,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue