1
- import { once } from 'node:events' ;
2
1
import { finished } from 'node:stream/promises' ;
3
2
4
3
import { expect } from 'chai' ;
@@ -372,10 +371,11 @@ describe.only('CRUD API', function () {
372
371
let count = 0 ;
373
372
cursor . match ( { a : 1 } ) ;
374
373
const stream = cursor . stream ( ) ;
374
+ const willFinish = finished ( stream , { cleanup : true } ) ;
375
375
stream . on ( 'data' , function ( ) {
376
376
count = count + 1 ;
377
377
} ) ;
378
- await once ( cursor , 'end' ) ;
378
+ await willFinish ;
379
379
test . equal ( 3 , count ) ;
380
380
} ) ;
381
381
@@ -387,13 +387,16 @@ describe.only('CRUD API', function () {
387
387
} ) ;
388
388
389
389
describe ( 'should correctly execute insert methods using crud api' , function ( ) {
390
- const db = client . db ( ) ;
390
+ let db : Db ;
391
+
392
+ before ( function ( ) {
393
+ db = client . db ( ) ;
394
+ } ) ;
391
395
392
396
it ( '#insertMany()' , async function ( ) {
393
397
const r = await db . collection ( 't2_1' ) . insertMany ( [ { a : 1 } , { a : 2 } ] ) ;
394
398
expect ( r ) . property ( 'insertedCount' ) . to . equal ( 2 ) ;
395
399
} ) ;
396
-
397
400
it ( 'bulk inserts' , async function ( ) {
398
401
const bulk = db . collection ( 't2_2' ) . initializeOrderedBulkOp ( ) ;
399
402
bulk . insert ( { a : 1 } ) ;
@@ -477,7 +480,11 @@ describe.only('CRUD API', function () {
477
480
requires : { topology : [ 'single' , 'replicaset' , 'sharded' ] }
478
481
} ,
479
482
function ( ) {
480
- const db = client . db ( ) ;
483
+ let db : Db ;
484
+
485
+ before ( function ( ) {
486
+ db = client . db ( ) ;
487
+ } ) ;
481
488
482
489
it ( 'legacy update' , async function ( ) {
483
490
const r = await db
0 commit comments