Updated back unit test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-05-14 17:32:52 +02:00
parent 2bb17f4a00
commit 9b085d13e1
1 changed files with 27 additions and 1 deletions

View File

@ -55,7 +55,7 @@ describe('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(5); 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() => {
@ -78,6 +78,32 @@ describe('regularizeClaim()', () => {
await app.models.Claim.regularizeClaim(ctx, claimFk); await app.models.Claim.regularizeClaim(ctx, claimFk);
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(4);
});
it('should send a chat message to the salesPerson when claim isPickUp is enabled', async() => {
const ctx = {
req: {
accessToken: {userId: 18},
headers: {origin: 'http://localhost'}
}
};
ctx.req.__ = (value, params) => {
return params.nickname;
};
const chatModel = app.models.Chat;
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
claimEnds.forEach(async claimEnd => {
claimEnd.updateAttributes({claimDestinationFk: okDestination});
});
const claim = await app.models.Claim.findById(claimFk);
await claim.updateAttribute('hasToPickUp', true);
await app.models.Claim.regularizeClaim(ctx, claimFk);
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno'); expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(5); expect(chatModel.sendCheckingPresence).toHaveBeenCalledTimes(5);
}); });