@@ -10,11 +10,19 @@ const { classNameToMethodList } = require('../tools/api');
1010const { byStrings, sorted, runMicroTask } = require ( '../tools/utils' ) ;
1111
1212// Dummy data to help with testing
13- const iLoveJs = 'mongodb://iLoveJavascript' ;
14- const client = new mongodbLegacy . MongoClient ( iLoveJs ) ;
15- const db = new mongodbLegacy . Db ( client , 'animals' ) ;
16- const collection = new mongodbLegacy . Collection ( db , 'pets' ) ;
17- const namespace = MongoDBNamespace . fromString ( 'animals.pets' ) ;
13+ let iLoveJs = 'mongodb://iLoveJavascript' ;
14+ let client = new mongodbLegacy . MongoClient ( iLoveJs ) ;
15+ let db = new mongodbLegacy . Db ( client , 'animals' ) ;
16+ let collection = new mongodbLegacy . Collection ( db , 'pets' , { } ) ;
17+ let namespace = MongoDBNamespace . fromString ( 'animals.pets' ) ;
18+
19+ function initialize ( ) {
20+ iLoveJs = 'mongodb://iLoveJavascript' ;
21+ client = new mongodbLegacy . MongoClient ( iLoveJs ) ;
22+ db = new mongodbLegacy . Db ( client , 'animals' ) ;
23+ collection = new mongodbLegacy . Collection ( db , 'pets' , { } ) ;
24+ namespace = MongoDBNamespace . fromString ( 'animals.pets' ) ;
25+ }
1826
1927// A map to helpers that can create instances of the overridden classes for testing
2028const OVERRIDDEN_CLASSES_GETTER = new Map ( [
@@ -126,6 +134,9 @@ describe('wrapper API', () => {
126134 possibleCallbackPositions,
127135 makeStub
128136 } of generateTests ( ) ) {
137+
138+ initialize ( ) ;
139+
129140 expect ( instance , apiName ) . to . have . property ( method ) . that . is . a ( 'function' ) ;
130141 const functionLength = instance [ method ] . length ;
131142
0 commit comments