From 084896c69a96db8c5e13e338f41177c7ee679caa Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Mon, 6 Aug 2018 12:00:29 +0200 Subject: [PATCH] #524 backend clone.js unit tests --- .../loopback/common/methods/item/specs/clone.spec.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/loopback/common/methods/item/specs/clone.spec.js b/services/loopback/common/methods/item/specs/clone.spec.js index cad4edf31..e971e1ee6 100644 --- a/services/loopback/common/methods/item/specs/clone.spec.js +++ b/services/loopback/common/methods/item/specs/clone.spec.js @@ -12,10 +12,19 @@ describe('item clone()', () => { nextItemId = nextAvailableId.id; }); - it('should', async() => { + it('should clone the given item and it should have the expected id', async() => { let itemFk = 1; let result = await app.models.Item.clone(itemFk); expect(result).toEqual(nextItemId); }); + + it('should attempt to clone the given item but give an error as it doesnt exist', async() => { + try { + let itemFk = 999; + await app.models.Item.clone(itemFk); + } catch (error) { + expect(error.toString()).toContain('Cannot convert undefined or null to object'); + } + }); });