@@ -862,23 +862,33 @@ describe('class MongoClient', function () {
862862 expect ( result2 ) . to . have . property ( 'ok' , 1 ) ;
863863 } ) ;
864864
865- it ( 'sends endSessions with noResponse set' , async ( ) => {
865+ it ( 'sends endSessions with w: 0 set' , async ( ) => {
866866 const session = client . startSession ( ) ; // make a session to be ended
867867 await client . db ( 'test' ) . command ( { ping : 1 } , { session } ) ;
868868 await session . endSession ( ) ;
869869
870870 const startedEvents : CommandStartedEvent [ ] = [ ] ;
871- const endEvents : Array < CommandFailedEvent | CommandSucceededEvent > = [ ] ;
871+ const endEvents : Array < CommandSucceededEvent > = [ ] ;
872872 client . on ( 'commandStarted' , event => startedEvents . push ( event ) ) ;
873873 client . on ( 'commandSucceeded' , event => endEvents . push ( event ) ) ;
874- client . on ( 'commandFailed' , event => endEvents . push ( event ) ) ;
875874
876875 await client . close ( ) ;
877876
878877 expect ( startedEvents ) . to . have . lengthOf ( 1 ) ;
879- expect ( startedEvents [ 0 ] ) . to . have . property ( 'commandName' , 'endSessions' ) ;
878+ const [
879+ {
880+ command : { endSessions, writeConcern }
881+ }
882+ ] = startedEvents ;
883+ expect ( endSessions ) . to . exist ;
884+ expect ( writeConcern ) . to . deep . equal ( { w : 0 } ) ;
880885 expect ( endEvents ) . to . have . lengthOf ( 1 ) ;
881- expect ( endEvents [ 0 ] ) . to . have . property ( 'reply' , undefined ) ; // noReponse: true
886+
887+ const [ { reply } ] = endEvents ;
888+
889+ // when unacknowledged writes are used, the driver uses `{ ok: 1 }` as a placeholder
890+ // `reply` in CommandSucceededEvents
891+ expect ( reply ) . to . deep . equal ( { ok : 1 } ) ;
882892 } ) ;
883893
884894 describe ( 'when server selection would return no servers' , ( ) => {
0 commit comments