32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
describe('ticket deleted()', () => {
|
|
let ticket;
|
|
|
|
beforeAll(async() => {
|
|
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
|
|
originalTicket.id = null;
|
|
ticket = await app.models.Ticket.create(originalTicket);
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await app.models.Ticket.destroyById(ticket.id);
|
|
});
|
|
|
|
it('should make sure the ticket is not deleted yet', async() => {
|
|
expect(ticket.isDeleted).toEqual(false);
|
|
});
|
|
|
|
it('should set a ticket to deleted and log the change on TicketState table', async() => {
|
|
let ctx = {req: {accessToken: {userId: 9}}};
|
|
let params = {id: ticket.id};
|
|
await app.models.Ticket.deleted(ctx, params);
|
|
|
|
let deletedTicket = await app.models.Ticket.findOne({where: {id: ticket.id}, fields: ['isDeleted']});
|
|
let changedState = await app.models.TicketState.findOne({where: {ticketFk: ticket.id}});
|
|
|
|
expect(deletedTicket.isDeleted).toEqual(true);
|
|
expect(changedState.stateFk).toEqual(17);
|
|
});
|
|
});
|