@@ -5,7 +5,6 @@ import * as sinon from 'sinon';
55
66import {
77 type Collection ,
8- type CommandFailedEvent ,
98 type CommandStartedEvent ,
109 type CommandSucceededEvent ,
1110 Db ,
@@ -862,23 +861,33 @@ describe('class MongoClient', function () {
862861 expect ( result2 ) . to . have . property ( 'ok' , 1 ) ;
863862 } ) ;
864863
865- it ( 'sends endSessions with noResponse set' , async ( ) => {
864+ it ( 'sends endSessions with w: 0 set' , async ( ) => {
866865 const session = client . startSession ( ) ; // make a session to be ended
867866 await client . db ( 'test' ) . command ( { ping : 1 } , { session } ) ;
868867 await session . endSession ( ) ;
869868
870869 const startedEvents : CommandStartedEvent [ ] = [ ] ;
871- const endEvents : Array < CommandFailedEvent | CommandSucceededEvent > = [ ] ;
870+ const endEvents : Array < CommandSucceededEvent > = [ ] ;
872871 client . on ( 'commandStarted' , event => startedEvents . push ( event ) ) ;
873872 client . on ( 'commandSucceeded' , event => endEvents . push ( event ) ) ;
874- client . on ( 'commandFailed' , event => endEvents . push ( event ) ) ;
875873
876874 await client . close ( ) ;
877875
878876 expect ( startedEvents ) . to . have . lengthOf ( 1 ) ;
879- expect ( startedEvents [ 0 ] ) . to . have . property ( 'commandName' , 'endSessions' ) ;
877+ const [
878+ {
879+ command : { endSessions, writeConcern }
880+ }
881+ ] = startedEvents ;
882+ expect ( endSessions ) . to . exist ;
883+ expect ( writeConcern ) . to . deep . equal ( { w : 0 } ) ;
880884 expect ( endEvents ) . to . have . lengthOf ( 1 ) ;
881- expect ( endEvents [ 0 ] ) . to . have . property ( 'reply' , undefined ) ; // noReponse: true
885+
886+ const [ { reply } ] = endEvents ;
887+
888+ // when unacknowledged writes are used, the driver uses `{ ok: 1 }` as a placeholder
889+ // `reply` in CommandSucceededEvents
890+ expect ( reply ) . to . deep . equal ( { ok : 1 } ) ;
882891 } ) ;
883892
884893 describe ( 'when server selection would return no servers' , ( ) => {
0 commit comments