@@ -588,30 +588,25 @@ describe('class MongoClient', function () {
588
588
} ) ;
589
589
590
590
it (
591
- 'creates topology and send ping when auth is enabled' ,
591
+ 'creates topology and checks out connection when auth is enabled' ,
592
592
{ requires : { auth : 'enabled' } } ,
593
593
async function ( ) {
594
- const commandToBeStarted = once ( client , 'commandStarted ' ) ;
594
+ const checkoutStarted = once ( client , 'connectionCheckOutStarted ' ) ;
595
595
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 ;
598
598
expect ( client ) . to . have . property ( 'topology' ) . that . is . instanceOf ( Topology ) ;
599
599
}
600
600
) ;
601
601
602
602
it (
603
- 'does not send ping when authentication is disabled' ,
603
+ 'does not checkout connection when authentication is disabled' ,
604
604
{ requires : { auth : 'disabled' } } ,
605
605
async function ( ) {
606
- const commandToBeStarted = once ( client , 'commandStarted ' ) ;
606
+ const checkoutStarted = once ( client , 'connectionCheckOutStarted ' ) ;
607
607
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 ;
615
610
expect ( client ) . to . have . property ( 'topology' ) . that . is . instanceOf ( Topology ) ;
616
611
}
617
612
) ;
@@ -1186,24 +1181,28 @@ describe('class MongoClient', function () {
1186
1181
1187
1182
const tests = [
1188
1183
// only skipInitialPing=true will have no events upon connect
1189
- { description : 'should skip ping command when set to true' , value : true , expectEvents : 0 } ,
1190
1184
{
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' ,
1192
1191
value : false ,
1193
1192
expectEvents : 1
1194
1193
} ,
1195
1194
{
1196
- description : 'should not skip ping command when unset' ,
1195
+ description : 'should not skip connection checkout command when unset' ,
1197
1196
value : undefined ,
1198
1197
expectEvents : 1
1199
1198
}
1200
1199
] ;
1201
1200
for ( const { description, value, expectEvents } of tests ) {
1202
1201
it ( description , async function ( ) {
1203
1202
const options = value === undefined ? { } : { __skipPingOnConnect : value } ;
1204
- const client = this . configuration . newClient ( { } , { ...options , monitorCommands : true } ) ;
1203
+ const client = this . configuration . newClient ( { } , { ...options } ) ;
1205
1204
const events = [ ] ;
1206
- client . on ( 'commandStarted ' , event => events . push ( event ) ) ;
1205
+ client . on ( 'connectionCheckOutStarted ' , event => events . push ( event ) ) ;
1207
1206
1208
1207
try {
1209
1208
await client . connect ( ) ;
@@ -1212,11 +1211,6 @@ describe('class MongoClient', function () {
1212
1211
}
1213
1212
1214
1213
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
- }
1220
1214
} ) ;
1221
1215
}
1222
1216
} ) ;
0 commit comments