salix/modules/ticket/back/methods/sale/specs/usesMana.spec.js

49 lines
1.3 KiB
JavaScript

const models = require('vn-loopback/server/server').models;
describe('sale usesMana()', () => {
const ctx = {
req: {
accessToken: {userId: 18}
}
};
it('should return that the worker uses mana', async() => {
const tx = await models.Sale.beginTransaction({});
try {
const options = {transaction: tx};
const teamCLopez = 96;
const userId = ctx.req.accessToken.userId;
const business = await models.Business.findOne({where: {workerFk: userId}}, options);
await business.updateAttribute('departmentFk', teamCLopez, options);
const usesMana = await models.Sale.usesMana(ctx, options);
expect(usesMana).toBe(true);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return that the worker not uses mana', async() => {
const tx = await models.Sale.beginTransaction({});
try {
const options = {transaction: tx};
const usesMana = await models.Sale.usesMana(ctx, options);
expect(usesMana).toBe(false);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});