Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"prettier": "^3.0.0",
"mocha": "^11.7.5",
"semantic-release": "^25.0.2",
"sinon": "^21.0.0",
"ts-node": "^10.9.1",
"tsx": "^4.21.0",
"typescript": "^5.1.6"
Expand Down
19 changes: 5 additions & 14 deletions test/asyncbox-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
asyncfilter,
waitForCondition,
} from '../lib/asyncbox.js';
import B from 'bluebird';
import sinon from 'sinon';

use(chaiAsPromised);

Expand Down Expand Up @@ -173,13 +171,6 @@ describe('retry', function () {
});

describe('waitForCondition', function () {
let requestSpy: sinon.SinonSpy;
beforeEach(function () {
requestSpy = sinon.spy(B, 'delay');
});
afterEach(function () {
requestSpy.restore();
});
it('should wait and succeed', async function () {
const ref = Date.now();
function condFn (): boolean {
Expand All @@ -203,14 +194,14 @@ describe('waitForCondition', function () {
expect(err.message).to.match(/Condition unmet/);
}
});
it('should not exceed implicit wait timeout', async function () {
it('should reduce interval to not exceed timeout', async function () {
const ref = Date.now();
function condFn (): boolean {
return Date.now() - ref > 15;
return Date.now() - ref > 25;
}
await (waitForCondition(condFn, {waitMs: 20, intervalMs: 10}));
const getLastCall = requestSpy.getCall(1);
expect(getLastCall.args[0]).to.be.at.most(10);
await waitForCondition(condFn, {waitMs: 30, intervalMs: 20});
const duration = Date.now() - ref;
expect(duration).to.be.below(35);
});
});

Expand Down