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

33 lines
1.0 KiB
JavaScript

const models = require('vn-loopback/server/server').models;
describe('invoiceIn toUnbook()', () => {
it('should check that invoiceIn is unbooked', 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 {
await models.InvoiceIn.toBook(ctx, invoiceInId, options);
const bookEntry = await models.InvoiceIn.toUnbook(ctx, invoiceInId, options);
const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options);
expect(bookEntry.accountingEntries).toEqual(4);
expect(bookEntry.isLinked).toBeFalsy();
expect(invoiceIn.isBooked).toEqual(false);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});