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

40 lines
1001 B
JavaScript
Raw Normal View History

const app = require('vn-loopback/server/server');
describe('sale updateConcept()', () => {
const saleId = 1;
let originalSale;
beforeAll(async done => {
originalSale = await app.models.Sale.findById(saleId);
done();
});
afterAll(async done => {
await originalSale.save();
done();
});
it('should throw if ID was undefined', async() => {
const newConcept = 'I am he new concept';
await app.models.Sale.updateConcept(undefined, newConcept)
.catch(response => {
expect(response).toEqual(new Error(`Model::findById requiere el argumento id`));
error = response;
});
expect(error).toBeDefined();
});
it('should update the sale concept', async() => {
const newConcept = 'I am the new concept';
let response = await app.models.Sale.updateConcept(saleId, newConcept);
expect(response.concept).toEqual(newConcept);
});
});