@@ -243,6 +243,56 @@ describe('class MongoClient', function () {
243
243
) ;
244
244
} ) ;
245
245
} ) ;
246
+
247
+ context ( 'when noDelay is not provided' , function ( ) {
248
+ let client ;
249
+ let spy ;
250
+
251
+ beforeEach ( async function ( ) {
252
+ spy = sinon . spy ( net , 'createConnection' ) ;
253
+ client = this . configuration . newClient ( ) ;
254
+ await client . connect ( ) ;
255
+ } ) ;
256
+
257
+ afterEach ( async function ( ) {
258
+ await client ?. close ( ) ;
259
+ spy . restore ( ) ;
260
+ } ) ;
261
+
262
+ it ( 'sets noDelay to true' , function ( ) {
263
+ expect ( spy ) . to . have . been . calledWith (
264
+ sinon . match ( {
265
+ noDelay : true
266
+ } )
267
+ ) ;
268
+ } ) ;
269
+ } ) ;
270
+
271
+ context ( 'when noDelay is provided' , function ( ) {
272
+ let client ;
273
+ let spy ;
274
+
275
+ beforeEach ( async function ( ) {
276
+ const options = { noDelay : false } ;
277
+ spy = sinon . spy ( net , 'createConnection' ) ;
278
+ const uri = this . configuration . url ( ) ;
279
+ client = new MongoClient ( uri , options ) ;
280
+ await client . connect ( ) ;
281
+ } ) ;
282
+
283
+ afterEach ( async function ( ) {
284
+ await client ?. close ( ) ;
285
+ spy . restore ( ) ;
286
+ } ) ;
287
+
288
+ it ( 'sets noDelay' , function ( ) {
289
+ expect ( spy ) . to . have . been . calledWith (
290
+ sinon . match ( {
291
+ noDelay : false
292
+ } )
293
+ ) ;
294
+ } ) ;
295
+ } ) ;
246
296
} ) ;
247
297
248
298
it ( 'Should correctly pass through appname' , {
@@ -999,12 +1049,12 @@ describe('class MongoClient', function () {
999
1049
metadata : { requires : { topology : [ 'single' ] } } ,
1000
1050
test : async function ( ) {
1001
1051
await client . connect ( ) ;
1002
- expect ( netSpy ) . to . have . been . calledWith ( {
1003
- autoSelectFamily : false ,
1004
- autoSelectFamilyAttemptTimeout : 100 ,
1005
- host : 'localhost' ,
1006
- port : 27017
1007
- } ) ;
1052
+ expect ( netSpy ) . to . have . been . calledWith (
1053
+ sinon . match ( {
1054
+ autoSelectFamily : false ,
1055
+ autoSelectFamilyAttemptTimeout : 100
1056
+ } )
1057
+ ) ;
1008
1058
}
1009
1059
} ) ;
1010
1060
} ) ;
@@ -1018,11 +1068,11 @@ describe('class MongoClient', function () {
1018
1068
metadata : { requires : { topology : [ 'single' ] } } ,
1019
1069
test : async function ( ) {
1020
1070
await client . connect ( ) ;
1021
- expect ( netSpy ) . to . have . been . calledWith ( {
1022
- autoSelectFamily : true ,
1023
- host : 'localhost' ,
1024
- port : 27017
1025
- } ) ;
1071
+ expect ( netSpy ) . to . have . been . calledWith (
1072
+ sinon . match ( {
1073
+ autoSelectFamily : true
1074
+ } )
1075
+ ) ;
1026
1076
}
1027
1077
} ) ;
1028
1078
} ) ;
0 commit comments