2018-08-10 15:17:53 +00:00
|
|
|
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
|
2018-09-13 13:13:42 +00:00
|
|
|
describe('ticket deleted()', () => {
|
2018-09-13 12:29:59 +00:00
|
|
|
let ticket;
|
2018-09-13 13:13:42 +00:00
|
|
|
|
2018-09-13 12:29:59 +00:00
|
|
|
afterAll(async() => {
|
|
|
|
await app.models.Ticket.upsert(ticket);
|
2018-09-13 13:13:42 +00:00
|
|
|
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};
|
2018-09-13 13:13:42 +00:00
|
|
|
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']});
|
2018-09-13 13:13:42 +00:00
|
|
|
let changedState = await app.models.TicketState.findOne({where: {id: 1}});
|
2018-09-13 12:29:59 +00:00
|
|
|
|
|
|
|
expect(deletedTicket.isDeleted).toEqual(true);
|
2018-09-13 13:13:42 +00:00
|
|
|
expect(changedState.stateFk).toEqual(17);
|
2018-08-10 15:17:53 +00:00
|
|
|
});
|
|
|
|
});
|