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

46 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

const models = require('vn-loopback/server/server').models;
describe('sale updateConcept()', () => {
2024-06-14 06:39:57 +00:00
const ctx = beforeAll.getCtx();
const saleId = 25;
it('should throw if ID was undefined', async() => {
const tx = await models.Sale.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const newConcept = 'not going to heppen';
await models.Sale.updateConcept(ctx, undefined, newConcept, options);
await tx.rollback();
2019-09-30 11:02:11 +00:00
} catch (e) {
await tx.rollback();
error = e;
2019-09-30 11:02:11 +00:00
}
expect(error).toBeDefined();
});
it('should update the sale concept', async() => {
const tx = await models.Sale.beginTransaction({});
try {
const options = {transaction: tx};
const newConcept = 'I am the new concept';
let response = await models.Sale.updateConcept(ctx, saleId, newConcept, options);
expect(response.concept).toEqual(newConcept);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});