updated unit test
gitea/salix/2094-claim_send_chat This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-02-13 14:46:18 +01:00
parent be07e33e5f
commit 5360c407d5
1 changed files with 4 additions and 1 deletions

View File

@ -5,6 +5,7 @@ fdescribe('regularizeClaim()', () => {
const pendentState = 1; const pendentState = 1;
const resolvedState = 3; const resolvedState = 3;
const trashDestination = 2; const trashDestination = 2;
const okDestination = 1;
const trashAddress = 12; const trashAddress = 12;
let claimEnds = []; let claimEnds = [];
let trashTicket; let trashTicket;
@ -55,6 +56,7 @@ fdescribe('regularizeClaim()', () => {
expect(claimBefore.claimStateFk).toEqual(pendentState); expect(claimBefore.claimStateFk).toEqual(pendentState);
expect(claimAfter.claimStateFk).toEqual(resolvedState); expect(claimAfter.claimStateFk).toEqual(resolvedState);
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Trash'); expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Trash');
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
}); });
it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => { it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => {
@ -73,11 +75,12 @@ fdescribe('regularizeClaim()', () => {
spyOn(chatModel, 'sendCheckingPresence').and.callThrough(); spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
claimEnds.forEach(async claimEnd => { claimEnds.forEach(async claimEnd => {
claimEnd.updateAttributes({claimDestinationFk: 1}); claimEnd.updateAttributes({claimDestinationFk: okDestination});
}); });
await app.models.Claim.regularizeClaim(ctx, params); await app.models.Claim.regularizeClaim(ctx, params);
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno'); expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
}); });
}); });