@@ -588,30 +588,25 @@ describe('class MongoClient', function () {
588588 } ) ;
589589
590590 it (
591- 'creates topology and send ping when auth is enabled' ,
591+ 'creates topology and checks out connection when auth is enabled' ,
592592 { requires : { auth : 'enabled' } } ,
593593 async function ( ) {
594- const commandToBeStarted = once ( client , 'commandStarted ' ) ;
594+ const checkoutStarted = once ( client , 'connectionCheckOutStarted ' ) ;
595595 await client . connect ( ) ;
596- const [ pingOnConnect ] = await commandToBeStarted ;
597- expect ( pingOnConnect ) . to . have . property ( 'commandName' , 'ping' ) ;
596+ const checkout = await checkoutStarted ;
597+ expect ( checkout ) . to . exist ;
598598 expect ( client ) . to . have . property ( 'topology' ) . that . is . instanceOf ( Topology ) ;
599599 }
600600 ) ;
601601
602602 it (
603- 'does not send ping when authentication is disabled' ,
603+ 'does not checkout connection when authentication is disabled' ,
604604 { requires : { auth : 'disabled' } } ,
605605 async function ( ) {
606- const commandToBeStarted = once ( client , 'commandStarted ' ) ;
606+ const checkoutStarted = once ( client , 'connectionCheckOutStarted ' ) ;
607607 await client . connect ( ) ;
608- const delayedFind = runLater ( async ( ) => {
609- await client . db ( ) . collection ( 'test' ) . findOne ( ) ;
610- } , 300 ) ;
611- const [ findOneOperation ] = await commandToBeStarted ;
612- // Proves that the first command started event that is emitted is a find and not a ping
613- expect ( findOneOperation ) . to . have . property ( 'commandName' , 'find' ) ;
614- await delayedFind ;
608+ const checkout = await checkoutStarted ;
609+ expect ( checkout ) . to . not . exist ;
615610 expect ( client ) . to . have . property ( 'topology' ) . that . is . instanceOf ( Topology ) ;
616611 }
617612 ) ;
@@ -1186,24 +1181,28 @@ describe('class MongoClient', function () {
11861181
11871182 const tests = [
11881183 // only skipInitialPing=true will have no events upon connect
1189- { description : 'should skip ping command when set to true' , value : true , expectEvents : 0 } ,
11901184 {
1191- description : 'should not skip ping command when set to false' ,
1185+ description : 'should skip connection checkout when set to true' ,
1186+ value : true ,
1187+ expectEvents : 0
1188+ } ,
1189+ {
1190+ description : 'should not skip connection checkout when set to false' ,
11921191 value : false ,
11931192 expectEvents : 1
11941193 } ,
11951194 {
1196- description : 'should not skip ping command when unset' ,
1195+ description : 'should not skip connection checkout command when unset' ,
11971196 value : undefined ,
11981197 expectEvents : 1
11991198 }
12001199 ] ;
12011200 for ( const { description, value, expectEvents } of tests ) {
12021201 it ( description , async function ( ) {
12031202 const options = value === undefined ? { } : { __skipPingOnConnect : value } ;
1204- const client = this . configuration . newClient ( { } , { ...options , monitorCommands : true } ) ;
1203+ const client = this . configuration . newClient ( { } , { ...options } ) ;
12051204 const events = [ ] ;
1206- client . on ( 'commandStarted ' , event => events . push ( event ) ) ;
1205+ client . on ( 'connectionCheckOutStarted ' , event => events . push ( event ) ) ;
12071206
12081207 try {
12091208 await client . connect ( ) ;
@@ -1212,11 +1211,6 @@ describe('class MongoClient', function () {
12121211 }
12131212
12141213 expect ( events ) . to . have . lengthOf ( expectEvents ) ;
1215- if ( expectEvents > 1 ) {
1216- for ( const event of events ) {
1217- expect ( event ) . to . have . property ( 'commandName' , 'ping' ) ;
1218- }
1219- }
12201214 } ) ;
12211215 }
12221216 } ) ;
0 commit comments