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

26 lines
939 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
});
it('should change the state of a ticket to deleted, and set the property isDeleted true', async() => {
2018-09-13 12:29:59 +00:00
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);
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
});
});