File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -8,17 +8,25 @@ import {
88 assertRejects ,
99 assertStringIncludes ,
1010} from "@std/assert" ;
11+ import { FakeTime } from "@std/testing/time" ;
1112
1213Deno . test ( "pooledMap()" , async ( ) => {
13- const start = performance . now ( ) ;
14+ using time = new FakeTime ( ) ;
15+
16+ const start = Date . now ( ) ;
1417 const results = pooledMap (
1518 2 ,
1619 [ 1 , 2 , 3 ] ,
1720 ( i ) => new Promise < number > ( ( r ) => setTimeout ( ( ) => r ( i ) , 300 ) ) ,
1821 ) ;
19- const array = await Array . fromAsync ( results ) ;
22+ const promise = Array . fromAsync ( results ) ;
23+ for ( const _ of Array ( 7 ) ) {
24+ time . tick ( 100 ) ;
25+ await time . runMicrotasks ( ) ;
26+ }
27+ const array = await promise ;
2028 assertEquals ( array , [ 1 , 2 , 3 ] ) ;
21- const diff = performance . now ( ) - start ;
29+ const diff = Date . now ( ) - start ;
2230
2331 assertGreaterOrEqual ( diff , 600 ) ;
2432 assertLess ( diff , 900 ) ;
You can’t perform that action at this time.
0 commit comments