Skip to content

Commit 07b47dc

Browse files
authored
test: adjust reduced interval check for waitForCondition (#56)
1 parent ee79cee commit 07b47dc

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"prettier": "^3.0.0",
6666
"mocha": "^11.7.5",
6767
"semantic-release": "^25.0.2",
68-
"sinon": "^21.0.0",
6968
"ts-node": "^10.9.1",
7069
"tsx": "^4.21.0",
7170
"typescript": "^5.1.6"

test/asyncbox-specs.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
asyncfilter,
1010
waitForCondition,
1111
} from '../lib/asyncbox.js';
12-
import B from 'bluebird';
13-
import sinon from 'sinon';
1412

1513
use(chaiAsPromised);
1614

@@ -173,13 +171,6 @@ describe('retry', function () {
173171
});
174172

175173
describe('waitForCondition', function () {
176-
let requestSpy: sinon.SinonSpy;
177-
beforeEach(function () {
178-
requestSpy = sinon.spy(B, 'delay');
179-
});
180-
afterEach(function () {
181-
requestSpy.restore();
182-
});
183174
it('should wait and succeed', async function () {
184175
const ref = Date.now();
185176
function condFn (): boolean {
@@ -203,14 +194,14 @@ describe('waitForCondition', function () {
203194
expect(err.message).to.match(/Condition unmet/);
204195
}
205196
});
206-
it('should not exceed implicit wait timeout', async function () {
197+
it('should reduce interval to not exceed timeout', async function () {
207198
const ref = Date.now();
208199
function condFn (): boolean {
209-
return Date.now() - ref > 15;
200+
return Date.now() - ref > 25;
210201
}
211-
await (waitForCondition(condFn, {waitMs: 20, intervalMs: 10}));
212-
const getLastCall = requestSpy.getCall(1);
213-
expect(getLastCall.args[0]).to.be.at.most(10);
202+
await waitForCondition(condFn, {waitMs: 30, intervalMs: 20});
203+
const duration = Date.now() - ref;
204+
expect(duration).to.be.below(35);
214205
});
215206
});
216207

0 commit comments

Comments
 (0)