File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -602,4 +602,25 @@ describe('bufferedAsyncMap() values', () => {
602602 await clock . runAllAsync ( ) ;
603603 await promisedResult ;
604604 } ) ;
605+
606+ it ( 'should give back pressure' , async ( ) => {
607+ baseAsyncIterable = yieldValuesOverTime ( 100 , ( i ) => i % 2 === 1 ? 2000 : 100 ) ;
608+ const baseAsyncIterator = baseAsyncIterable [ Symbol . asyncIterator ] ( ) ;
609+
610+ const nextSpy = sinon . spy ( baseAsyncIterator , 'next' ) ;
611+
612+ const asyncIterator = bufferedAsyncMap (
613+ baseAsyncIterable ,
614+ async ( item ) => item ,
615+ { bufferSize : 10 }
616+ ) ;
617+
618+ await clock . runAllAsync ( ) ;
619+ nextSpy . should . have . callCount ( 10 ) ;
620+
621+ await asyncIterator . next ( ) . should . eventually . be . an ( 'object' ) . with . property ( 'value' ) . that . is . a ( 'number' ) ;
622+
623+ await clock . runAllAsync ( ) ;
624+ nextSpy . should . have . callCount ( 11 ) ;
625+ } ) ;
605626} ) ;
You can’t perform that action at this time.
0 commit comments