feat: refs #7936 add back test for updateInvoiceIn
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
c9cf96676b
commit
ac87905351
|
@ -0,0 +1,59 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
const invoiceInId = 1;
|
||||
const supplierId = 791;
|
||||
fdescribe('invoiceIn updateInvoiceIn()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should update the invoice', async() => {
|
||||
const invoiceBefore = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
await update(ctx, options);
|
||||
const invoiceAfter = await models.InvoiceIn.findById(invoiceInId, null, options);
|
||||
|
||||
expect(invoiceAfter.supplierFk).not.toBe(invoiceBefore.supplierFk);
|
||||
expect(invoiceAfter.supplierFk).toBe(supplierId);
|
||||
});
|
||||
|
||||
it('should not update the invoice if is booked', async() => {
|
||||
let error;
|
||||
try {
|
||||
await models.InvoiceIn.toBook(ctx, invoiceInId, options);
|
||||
await update(ctx, options);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error.message).toBe('InvoiceIn is already booked');
|
||||
});
|
||||
});
|
||||
|
||||
async function update(ctx, opts) {
|
||||
const supplierRef = 'mockRef';
|
||||
const currencyId = 1;
|
||||
await models.InvoiceIn.updateInvoiceIn(ctx,
|
||||
invoiceInId,
|
||||
supplierId,
|
||||
supplierRef,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
currencyId,
|
||||
undefined,
|
||||
undefined,
|
||||
opts);
|
||||
}
|
|
@ -72,7 +72,6 @@ module.exports = Self => {
|
|||
) => {
|
||||
let tx;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
const models = Self.app.models;
|
||||
|
||||
if (typeof options == 'object') Object.assign(myOptions, options);
|
||||
|
||||
|
|
Loading…
Reference in New Issue