salix/services/loopback/common/methods/ticket/specs/deleted.spec.js

29 lines
1013 B
JavaScript
Raw Normal View History

2018-08-10 15:17:53 +00:00
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket deleted()', () => {
2018-09-13 12:29:59 +00:00
let ticket;
2018-09-13 12:29:59 +00:00
afterAll(async() => {
await app.models.Ticket.upsert(ticket);
await app.models.TicketTracking.create({ticketFk: ticket.id, stateFk: 3});
2018-09-13 12:29:59 +00:00
});
2018-09-27 11:13:02 +00:00
it('should make sure the ticket is not deleted yet', async() => {
2018-09-13 12:29:59 +00:00
ticket = await app.models.Ticket.findOne({where: {id: 1}});
expect(ticket.isDeleted).toEqual(false);
2018-09-13 13:29:38 +00:00
});
it('should set a ticket to deleted and log the change on TicketState table', async() => {
let ctx = {req: {accessToken: {userId: 9}}};
let params = {id: 1};
await app.models.Ticket.deleted(ctx, params);
2018-08-10 15:17:53 +00:00
2018-09-13 12:29:59 +00:00
let deletedTicket = await app.models.Ticket.findOne({where: {id: 1}, fields: ['isDeleted']});
let changedState = await app.models.TicketState.findOne({where: {id: 1}});
2018-09-13 12:29:59 +00:00
expect(deletedTicket.isDeleted).toEqual(true);
expect(changedState.stateFk).toEqual(17);
2018-08-10 15:17:53 +00:00
});
});