salix/modules/entry/back/methods/entry/specs/deleteBuys.spec.js

34 lines
835 B
JavaScript

const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('sale deleteBuys()', () => {
const activeCtx = {
accessToken: {userId: 18},
};
const ctx = {
req: activeCtx
};
it('should delete the buy', async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
const tx = await models.Entry.beginTransaction({});
const options = {transaction: tx};
ctx.args = {buys: [{id: 1}]};
try {
const result = await models.Buy.deleteBuys(ctx, options);
expect(result).toEqual([{count: 1}]);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});