promise-retry: add a retry function to abort early
This commit is contained in:
@@ -35,4 +35,15 @@ describe('promiseRetry', function () {
|
||||
|
||||
expect(result).to.be(42);
|
||||
});
|
||||
|
||||
it('can abort with 1 try only', async function () {
|
||||
let tryCount = 0;
|
||||
const [error] = await safe(promiseRetry({ times: 5, interval: 1000, retry: () => false }, async () => {
|
||||
++tryCount;
|
||||
throw tryCount;
|
||||
}));
|
||||
|
||||
expect(tryCount).to.be(1);
|
||||
expect(error).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user