File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments