41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
|
const app = require('vn-loopback/server/server');
|
||
|
|
||
|
describe('ticket setDelivered()', () => {
|
||
|
let ticketOne;
|
||
|
let ticketTwo;
|
||
|
|
||
|
beforeAll(async done => {
|
||
|
let originalTicketOne = await app.models.Ticket.findById(8);
|
||
|
let originalTicketTwo = await app.models.Ticket.findById(10);
|
||
|
|
||
|
originalTicketOne.id = null;
|
||
|
originalTicketTwo.id = null;
|
||
|
ticketOne = await app.models.Ticket.create(originalTicketOne);
|
||
|
ticketTwo = await app.models.Ticket.create(originalTicketTwo);
|
||
|
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
afterAll(async done => {
|
||
|
await app.models.Ticket.destroyById(ticketOne.id);
|
||
|
await app.models.Ticket.destroyById(ticketTwo.id);
|
||
|
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
it('should return an array of the tickets states changed to delivered', async() => {
|
||
|
let ctx = {req: {accessToken: {userId: 49}}};
|
||
|
let delivered = await app.models.State.findOne({where: {code: 'delivered'}, fields: ['id']});
|
||
|
|
||
|
let params = [ticketOne.id, ticketTwo.id];
|
||
|
let res = await app.models.TicketTracking.setDelivered(ctx, params);
|
||
|
|
||
|
expect(res[0].ticketFk).toEqual(ticketOne.id);
|
||
|
expect(res[0].stateFk).toEqual(delivered.id);
|
||
|
|
||
|
expect(res[1].ticketFk).toEqual(ticketTwo.id);
|
||
|
expect(res[1].stateFk).toEqual(delivered.id);
|
||
|
});
|
||
|
});
|
||
|
|