99 asyncfilter ,
1010 waitForCondition ,
1111} from '../lib/asyncbox.js' ;
12- import B from 'bluebird' ;
13- import sinon from 'sinon' ;
1412
1513use ( chaiAsPromised ) ;
1614
@@ -173,13 +171,6 @@ describe('retry', function () {
173171} ) ;
174172
175173describe ( '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 ( / C o n d i t i o n u n m e t / ) ;
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