Updated back unit test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2bb17f4a00
commit
9b085d13e1
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue