salix/modules/invoiceIn/back/methods/invoice-in/specs/toBook.spec.js

35 lines
1023 B
JavaScript
Raw Permalink Normal View History

2021-09-24 06:24:34 +00:00
const models = require('vn-loopback/server/server').models;
2021-12-14 08:51:12 +00:00
describe('invoiceIn toBook()', () => {
2021-09-24 06:24:34 +00:00
it('should check that invoiceIn is booked', async() => {
const userId = 1;
const ctx = {
req: {
accessToken: {userId: userId},
headers: {origin: 'http://localhost:5000'},
}
};
const invoiceInId = 1;
const tx = await models.InvoiceIn.beginTransaction({});
const options = {transaction: tx};
try {
const invoiceInBefore = await models.InvoiceIn.findById(invoiceInId, null, options);
expect(invoiceInBefore.isBooked).toEqual(false);
await models.InvoiceIn.toBook(ctx, invoiceInId, options);
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
expect(invoiceIn.isBooked).toEqual(true);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});