@@ -243,6 +243,56 @@ describe('class MongoClient', function () {
243243 ) ;
244244 } ) ;
245245 } ) ;
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+ } ) ;
246296 } ) ;
247297
248298 it ( 'Should correctly pass through appname' , {
@@ -999,12 +1049,12 @@ describe('class MongoClient', function () {
9991049 metadata : { requires : { topology : [ 'single' ] } } ,
10001050 test : async function ( ) {
10011051 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+ ) ;
10081058 }
10091059 } ) ;
10101060 } ) ;
@@ -1018,11 +1068,11 @@ describe('class MongoClient', function () {
10181068 metadata : { requires : { topology : [ 'single' ] } } ,
10191069 test : async function ( ) {
10201070 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+ ) ;
10261076 }
10271077 } ) ;
10281078 } ) ;
0 commit comments