restore fixtures makeInvoice
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-04-12 14:53:17 +02:00
parent dbe56b2496
commit b5fe7a6fae
1 changed files with 11 additions and 3 deletions

View File

@ -1,20 +1,28 @@
const app = require('vn-loopback/server/server');
describe('ticket makeInvoice()', () => {
let invoice;
afterAll(async done => {
let ticket = await app.models.Ticket.findById(11);
ticket.updateAttributes({refFk: null});
let ticketTracking = await app.models.TicketTracking.findOne({order: 'id DESC', limit: 1});
ticketTracking.destroy();
let invoiceOut = await app.models.InvoiceOut.findById(invoice.invoiceFk);
invoiceOut.destroy();
done();
});
it('should invoice a ticket', async() => {
let ctx = {req: {accessToken: {userId: 9}}};
let ticketFk = 11;
let result = await app.models.Ticket.makeInvoice(ctx, ticketFk);
invoice = await app.models.Ticket.makeInvoice(ctx, ticketFk);
expect(result.invoiceFk).not.toBeNaN();
expect(result.serial).toEqual('T');
expect(invoice.invoiceFk).not.toBeNaN();
expect(invoice.serial).toEqual('T');
});
it('should not invoice an already invoiced ticket', async() => {