From 18fe2e16af178b8d79eef01b451f185f4b91d2be Mon Sep 17 00:00:00 2001 From: gerard Date: Mon, 17 Sep 2018 15:10:46 +0200 Subject: [PATCH] updated test --- .../methods/order/specs/isEditable.spec.js | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/services/order/common/methods/order/specs/isEditable.spec.js b/services/order/common/methods/order/specs/isEditable.spec.js index f0d93c6db..99d8d98f1 100644 --- a/services/order/common/methods/order/specs/isEditable.spec.js +++ b/services/order/common/methods/order/specs/isEditable.spec.js @@ -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(); }); });