26 lines
939 B
JavaScript
26 lines
939 B
JavaScript
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
describe('ticket deleted()', () => {
|
|
let ticket;
|
|
|
|
afterAll(async() => {
|
|
await app.models.Ticket.upsert(ticket);
|
|
await app.models.TicketTracking.create({ticketFk: ticket.id, stateFk: 3});
|
|
});
|
|
|
|
it('should change the state of a ticket to deleted, and set the property isDeleted true', async() => {
|
|
ticket = await app.models.Ticket.findOne({where: {id: 1}});
|
|
|
|
expect(ticket.isDeleted).toEqual(false);
|
|
ctx = {req: {accessToken: {userId: 9}}};
|
|
params = {id: 1};
|
|
await app.models.Ticket.deleted(ctx, params);
|
|
|
|
let deletedTicket = await app.models.Ticket.findOne({where: {id: 1}, fields: ['isDeleted']});
|
|
let changedState = await app.models.TicketState.findOne({where: {id: 1}});
|
|
|
|
expect(deletedTicket.isDeleted).toEqual(true);
|
|
expect(changedState.stateFk).toEqual(17);
|
|
});
|
|
});
|