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 UserError = require('vn-loopback/common/helpers').UserError;
describe('order isEditable()', () => {
it('should throw an error if the order given is not editable', async() => {
let error;
it('should return false when the given order is not editable', async() => {
let isEditable = await app.models.Order.isEditable(2);
await app.models.Order.isEditable(2)
.catch(e => {
error = e;
});
expect(error).toEqual(new UserError('This order is not editable'));
expect(isEditable).toBeFalsy();
});
it('should throw an error if the order given does not exists', async() => {
let error;
it('should return false when the given order doesnt exists', async() => {
let isEditable = await app.models.Order.isEditable(99999);
await app.models.Order.isEditable(99999)
.catch(e => {
error = e;
});
expect(isEditable).toBeFalsy();
});
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();
});
});