2019-09-26 07:05:18 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
|
|
|
describe('sale updateConcept()', () => {
|
2021-05-26 07:14:18 +00:00
|
|
|
const ctx = {req: {accessToken: {userId: 9}}};
|
2019-09-26 07:05:18 +00:00
|
|
|
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() => {
|
2019-09-30 11:02:11 +00:00
|
|
|
let err;
|
2019-09-26 07:05:18 +00:00
|
|
|
const newConcept = 'I am he new concept';
|
|
|
|
|
2019-09-30 11:02:11 +00:00
|
|
|
try {
|
2021-05-26 07:14:18 +00:00
|
|
|
await app.models.Sale.updateConcept(ctx, undefined, newConcept);
|
2019-09-30 11:02:11 +00:00
|
|
|
} catch (e) {
|
|
|
|
err = e;
|
|
|
|
}
|
2019-09-26 07:05:18 +00:00
|
|
|
|
2019-09-30 11:02:11 +00:00
|
|
|
expect(err).toBeDefined();
|
2019-09-26 07:05:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should update the sale concept', async() => {
|
|
|
|
const newConcept = 'I am the new concept';
|
|
|
|
|
2021-05-26 07:14:18 +00:00
|
|
|
let response = await app.models.Sale.updateConcept(ctx, saleId, newConcept);
|
2019-09-26 07:05:18 +00:00
|
|
|
|
|
|
|
expect(response.concept).toEqual(newConcept);
|
|
|
|
});
|
|
|
|
});
|