updated test

This commit is contained in:
gerard 2018-09-17 15:10:46 +02:00
parent 6b155c6485
commit 18fe2e16af
1 changed files with 11 additions and 16 deletions

View File

@ -1,26 +1,21 @@
const app = require(`${servicesDir}/order/server/server`); const app = require(`${servicesDir}/order/server/server`);
const UserError = require('vn-loopback/common/helpers').UserError;
describe('order isEditable()', () => { describe('order isEditable()', () => {
it('should throw an error if the order given is not editable', async() => { it('should return false when the given order is not editable', async() => {
let error; let isEditable = await app.models.Order.isEditable(2);
await app.models.Order.isEditable(2) expect(isEditable).toBeFalsy();
.catch(e => {
error = e;
});
expect(error).toEqual(new UserError('This order is not editable'));
}); });
it('should throw an error if the order given does not exists', async() => { it('should return false when the given order doesnt exists', async() => {
let error; let isEditable = await app.models.Order.isEditable(99999);
await app.models.Order.isEditable(99999) expect(isEditable).toBeFalsy();
.catch(e => { });
error = e;
});
expect(error).toEqual(new UserError('This order is not editable')); it('should return true when the given order is editable', async() => {
let isEditable = await app.models.Order.isEditable(1);
expect(isEditable).toBeTruthy();
}); });
}); });