@@ -284,22 +284,24 @@ describe('Client', () => {
284284 expect ( mockSession . end ) . not . toHaveBeenCalled ( ) ;
285285 } ) ;
286286
287- // test.serial('requests the conversation then patches the participant to disconnected', async t => {
288- // const sessionId = random();
289- // const conversationId = random();
290- // const participantId = PARTICIPANT_ID;
291- // const { sdk, getConversation, patchConversation } = mockApis({ conversationId, participantId });
292- // await sdk.initialize();
293-
294- // const mockSession = { id: sessionId, conversationId, end: sinon.stub() };
295- // sdk._sessionManager.sessions = {};
296- // sdk._sessionManager.sessions[sessionId] = mockSession;
297-
298- // await sdk.endSession({ conversationId });
299- // getConversation.done();
300- // patchConversation.done();
301- // sinon.assert.notCalled(mockSession.end);
302- // });
287+ test ( 'ends the session directly if patching the conversation fails' , async ( ) => {
288+ const sessionId = random ( ) ;
289+ const conversationId = random ( ) ;
290+ const participantId = PARTICIPANT_ID ;
291+ const { sdk, getConversation, patchConversation } = mockApis ( { conversationId, participantId, failConversationPatch : true } ) ;
292+ await sdk . initialize ( ) ;
293+
294+ const mockSession = { id : sessionId , conversationId, end : jest . fn ( ) } ;
295+ sdk . _sessionManager . sessions = { } ;
296+ sdk . _sessionManager . sessions [ sessionId ] = mockSession ;
297+
298+ await sdk . endSession ( { id : sessionId } )
299+ . catch ( ( ) => {
300+ getConversation . done ( ) ;
301+ patchConversation . done ( ) ;
302+ expect ( mockSession . end ) . toHaveBeenCalled ( ) ;
303+ } ) ;
304+ } ) ;
303305
304306 test ( 'rejects if not provided either an id or a conversationId' , async done => {
305307 const { sdk } = mockApis ( ) ;
0 commit comments