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

32 lines
986 B
JavaScript

const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('InvoiceOut refund()', () => {
const userId = 5;
const ctx = {req: {accessToken: userId}, args: {}};
const withWarehouse = true;
const activeCtx = {
accessToken: {userId: userId},
};
it('should return the ids for the created refund tickets', async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
try {
await models.TicketRefund.destroyAll(null, options);
const result = await models.InvoiceOut.refund(ctx, 'T1111111', withWarehouse, options);
expect(result).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});