From 99499b214e60ff656d9c14d436d0ede4ae365cf6 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 11 Apr 2022 14:43:20 +0200 Subject: [PATCH] Updated RocketChat unit tests --- back/methods/chat/spec/notifyIssue.spec.js | 8 +++----- back/methods/chat/spec/send.spec.js | 5 ++--- back/methods/chat/spec/sendCheckingPresence.spec.js | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/back/methods/chat/spec/notifyIssue.spec.js b/back/methods/chat/spec/notifyIssue.spec.js index 96117c2c0..e20d43142 100644 --- a/back/methods/chat/spec/notifyIssue.spec.js +++ b/back/methods/chat/spec/notifyIssue.spec.js @@ -13,10 +13,9 @@ describe('Chat notifyIssue()', () => { spyOn(chatModel, 'send').and.callThrough(); spyOn(osTicketModel, 'rawSql').and.returnValue([]); - const response = await chatModel.notifyIssues(ctx); + await chatModel.notifyIssues(ctx); expect(chatModel.send).not.toHaveBeenCalled(); - expect(response).toBeUndefined(); }); it(`should return a response calling the send() method`, async() => { @@ -27,16 +26,15 @@ describe('Chat notifyIssue()', () => { username: 'batman', subject: 'Issue title'} ]); + // eslint-disable-next-line max-len const expectedMessage = `@all ➔ There's a new urgent ticket:\r\n[ID: *00001* - Issue title (@batman)](https://cau.verdnatura.es/scp/tickets.php?id=1)`; const department = await app.models.Department.findById(departmentId); let orgChatName = department.chatName; await department.updateAttribute('chatName', 'IT'); - const response = await chatModel.notifyIssues(ctx); + await chatModel.notifyIssues(ctx); - expect(response.statusCode).toEqual(200); - expect(response.message).toEqual('Fake notification sent'); expect(chatModel.send).toHaveBeenCalledWith(ctx, '#IT', expectedMessage); // restores diff --git a/back/methods/chat/spec/send.spec.js b/back/methods/chat/spec/send.spec.js index 2c23bb591..634e1d420 100644 --- a/back/methods/chat/spec/send.spec.js +++ b/back/methods/chat/spec/send.spec.js @@ -5,14 +5,13 @@ describe('Chat send()', () => { let ctx = {req: {accessToken: {userId: 1}}}; let response = await app.models.Chat.send(ctx, '@salesPerson', 'I changed something'); - expect(response.statusCode).toEqual(200); - expect(response.message).toEqual('Fake notification sent'); + expect(response).toEqual(true); }); it('should retrun false as response', async() => { let ctx = {req: {accessToken: {userId: 18}}}; let response = await app.models.Chat.send(ctx, '@salesPerson', 'I changed something'); - expect(response).toBeFalsy(); + expect(response).toEqual(false); }); }); diff --git a/back/methods/chat/spec/sendCheckingPresence.spec.js b/back/methods/chat/spec/sendCheckingPresence.spec.js index 2c48ef02c..712e7f947 100644 --- a/back/methods/chat/spec/sendCheckingPresence.spec.js +++ b/back/methods/chat/spec/sendCheckingPresence.spec.js @@ -20,10 +20,8 @@ describe('Chat sendCheckingPresence()', () => { }) ); - const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something'); + await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something'); - expect(response.statusCode).toEqual(200); - expect(response.message).toEqual('Fake notification sent'); expect(chatModel.send).toHaveBeenCalledWith(ctx, '@HankPym', 'I changed something'); }); @@ -47,10 +45,8 @@ describe('Chat sendCheckingPresence()', () => { const department = await models.Department.findById(departmentId, null, options); await department.updateAttribute('chatName', 'cooler'); - const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something'); + await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something'); - expect(response.statusCode).toEqual(200); - expect(response.message).toEqual('Fake notification sent'); expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', '@HankPym ➔ I changed something'); await tx.rollback();