11import { expect } from 'chai' ;
2- import { once } from 'events' ;
32
43import { getCSFLEKMSProviders } from '../../csfle-kms-providers' ;
54import { type Collection , type FindCursor , type MongoClient } from '../../mongodb' ;
@@ -626,13 +625,19 @@ describe('MongoClient.close() Integration', () => {
626625 } ) ;
627626
628627 describe ( 'Node.js resource: Socket' , ( ) => {
629- it . skip ( 'no sockets remain after client.close()' , metadata , async ( ) => { } ) ;
628+ it . skip ( 'no sockets remain after client.close()' , metadata , async ( ) => null ) ;
630629 } ) ;
631630 } ) ;
632631 } ) ;
633632
634633 describe ( 'Server resource: Cursor' , ( ) => {
635- describe ( 'after cursors are created' , ( ) => {
634+ const metadata : MongoDBMetadataUI = {
635+ requires : {
636+ mongodb : '>=4.2.0' // MongoServerError: Unrecognized option 'idleCursors' in $currentOp stage. on 4.0
637+ }
638+ } ;
639+
640+ describe ( 'after cursors are created' , metadata , ( ) => {
636641 let client : MongoClient ;
637642 let coll : Collection ;
638643 let cursor : FindCursor ;
@@ -657,31 +662,35 @@ describe('MongoClient.close() Integration', () => {
657662 await cursor ?. close ( ) ;
658663 } ) ;
659664
660- it ( 'all active server-side cursors are closed by client.close()' , async function ( ) {
661- const getCursors = async ( ) => {
662- const cursors = await utilClient
663- . db ( 'admin' )
664- . aggregate ( [ { $currentOp : { idleCursors : true } } ] )
665- . toArray ( ) ;
666-
667- return cursors . filter (
668- c =>
669- c . ns !== 'local.oplog.rs' &&
670- ( c . type === 'idleCursor' || ( c . type === 'op' && c . desc === 'getMore' ) )
671- ) ; // all idle cursors
672- } ;
665+ it (
666+ 'all active server-side cursors are closed by client.close()' ,
667+ metadata ,
668+ async function ( ) {
669+ const getCursors = async ( ) => {
670+ const cursors = await utilClient
671+ . db ( 'admin' )
672+ . aggregate ( [ { $currentOp : { idleCursors : true } } ] )
673+ . toArray ( ) ;
674+
675+ return cursors . filter (
676+ c =>
677+ c . ns !== 'local.oplog.rs' &&
678+ ( c . type === 'idleCursor' || ( c . type === 'op' && c . desc === 'getMore' ) )
679+ ) ; // all idle cursors
680+ } ;
673681
674- cursor = coll . find ( { } , { batchSize : 1 } ) ;
675- await cursor . next ( ) ;
682+ cursor = coll . find ( { } , { batchSize : 1 } ) ;
683+ await cursor . next ( ) ;
676684
677- // assert creation
678- expect ( await getCursors ( ) ) . to . not . be . empty ;
685+ // assert creation
686+ expect ( await getCursors ( ) ) . to . not . be . empty ;
679687
680- await client . close ( ) ;
688+ await client . close ( ) ;
681689
682- // assert clean-up
683- expect ( await getCursors ( ) ) . to . be . empty ;
684- } ) ;
690+ // assert clean-up
691+ expect ( await getCursors ( ) ) . to . be . empty ;
692+ }
693+ ) ;
685694 } ) ;
686695 } ) ;
687696} ) ;
0 commit comments