46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('sale updateConcept()', () => {
|
|
const ctx = {req: {accessToken: {userId: 9}}};
|
|
const saleId = 1;
|
|
|
|
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();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
error = e;
|
|
}
|
|
|
|
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;
|
|
}
|
|
});
|
|
});
|