salix/modules/invoiceOut/back/methods/invoiceOut/specs/summary.spec.js

56 lines
1.7 KiB
JavaScript

const models = require('vn-loopback/server/server').models;
describe('invoiceOut summary()', () => {
it('should return a summary object containing data from one invoiceOut', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
try {
const result = await models.InvoiceOut.summary(1, options);
expect(result.invoiceOut.id).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should return a summary object containing it's supplier country`, async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
try {
const summary = await models.InvoiceOut.summary(1, options);
const supplier = summary.invoiceOut.supplier();
expect(summary.invoiceOut.ref).toEqual('T1111111');
expect(supplier.id).toEqual(442);
expect(supplier.countryFk).toEqual(1);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it(`should return a summary object containing idata from it's tax types`, async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
try {
const summary = await models.InvoiceOut.summary(1, options);
expect(summary.invoiceOut.ref).toEqual('T1111111');
expect(summary.invoiceOut.taxesBreakdown.length).toEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});