updated unit test
gitea/salix/2094-claim_send_chat This commit looks good
Details
gitea/salix/2094-claim_send_chat This commit looks good
Details
This commit is contained in:
parent
39470e837b
commit
be07e33e5f
|
@ -1,6 +1,6 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('regularizeClaim()', () => {
|
fdescribe('regularizeClaim()', () => {
|
||||||
const claimFk = 1;
|
const claimFk = 1;
|
||||||
const pendentState = 1;
|
const pendentState = 1;
|
||||||
const resolvedState = 3;
|
const resolvedState = 3;
|
||||||
|
@ -21,15 +21,20 @@ describe('regularizeClaim()', () => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change claim state to resolved', async() => {
|
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
|
||||||
const ctx = {req: {
|
const ctx = {
|
||||||
accessToken: {userId: 18},
|
req: {
|
||||||
headers: {origin: 'http://localhost'}}
|
accessToken: {userId: 18},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ctx.req.__ = value => {
|
ctx.req.__ = (value, params) => {
|
||||||
return value;
|
return params.nickname;
|
||||||
};
|
};
|
||||||
|
|
||||||
let params = {claimFk: claimFk};
|
let params = {claimFk: claimFk};
|
||||||
|
const chatModel = app.models.Chat;
|
||||||
|
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, {
|
claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, {
|
||||||
claimFk: claimFk,
|
claimFk: claimFk,
|
||||||
|
@ -49,5 +54,30 @@ describe('regularizeClaim()', () => {
|
||||||
expect(trashTicket.addressFk).toEqual(trashAddress);
|
expect(trashTicket.addressFk).toEqual(trashAddress);
|
||||||
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');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should send a chat message with value "Bueno" and then change claim state to resolved', async() => {
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 18},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.req.__ = (value, params) => {
|
||||||
|
return params.nickname;
|
||||||
|
};
|
||||||
|
|
||||||
|
let params = {claimFk: claimFk};
|
||||||
|
const chatModel = app.models.Chat;
|
||||||
|
spyOn(chatModel, 'sendCheckingPresence').and.callThrough();
|
||||||
|
|
||||||
|
claimEnds.forEach(async claimEnd => {
|
||||||
|
claimEnd.updateAttributes({claimDestinationFk: 1});
|
||||||
|
});
|
||||||
|
|
||||||
|
await app.models.Claim.regularizeClaim(ctx, params);
|
||||||
|
|
||||||
|
expect(chatModel.sendCheckingPresence).toHaveBeenCalledWith(ctx, 18, 'Bueno');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue