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 make the ticket is not deleted yet', async() => { ticket = await app.models.Ticket.findOne({where: {id: 1}}); 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: 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); }); });