Skip to content

Commit 425e212

Browse files
authored
Merge pull request #46 from AddSearch/sc-6034/typescript-support-for-js-client-library
feat: [sc-6034] Typescript support for js-client library
2 parents 1cdc1f0 + b25e125 commit 425e212

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/throttle.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@ describe('throttle', function() {
2323
await sleep(sleepTime);
2424
}
2525

26-
assert.equal(expectedExecutions, executions);
26+
assert.equal(executions, expectedExecutions);
2727
});
2828

2929
it('function should be throttled (4 function calls in 600ms', async function() {
3030
this.timeout(5000);
3131
var functionCalls = 30;
3232
var sleepTime = 20; // 30*20 = 600 ms
3333
var throttleDelay = 200;
34-
var expectedExecutions = 3 + 1; // Call functions for 600 ms with 200 ms throttle = 3 calls + one last call
34+
// Call functions for 600 ms with 200 ms throttle = 3 calls + one last call
35+
// this is LowerBound as in slower environments there could be more executions
36+
// less than the lowerBound isn't possible due to the deterministic sleepTime, and throttleDelay values
37+
var expectedExecutionsLowerBound = 3 + 1;
3538
var executions = 0;
3639

3740
var f = throttle(throttleDelay, function() {
@@ -42,8 +45,7 @@ describe('throttle', function() {
4245
f();
4346
await sleep(sleepTime);
4447
}
45-
46-
assert.equal(expectedExecutions, executions);
48+
assert.equal(expectedExecutionsLowerBound <= executions, true);
4749
});
4850

4951
});

0 commit comments

Comments
 (0)