From 976c5b7ba8f8bbda1b651a4db4345b6fa51176ac Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 22 Mar 2024 11:42:19 +0100 Subject: [PATCH] refs #6964 feat:advice for olderItem --- .../item-shelving/specs/hasItemOlder.spec.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js diff --git a/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js b/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js new file mode 100644 index 0000000000..b6e501d857 --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js @@ -0,0 +1,45 @@ + +const {models} = require('vn-loopback/server/server'); + +fdescribe('itemShelving hasOlder()', () => { + it('should return false because there are not older items', async() => { + const shelvingFkIn = 'GVC'; + const shelvingFkOut = 'HEJ'; + const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, shelvingFkOut); + + expect(result).toBe(false); + }); + + it('should return false because there are not older items in parking', async() => { + const shelvingFkIn = 'HEJ'; + const parking = '700-01'; + const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking); + + expect(result).toBe(false); + }); + + it('should return true because there is an older item', async() => { + const shelvingFkIn = 'UXN'; + const shelvingFkOut = 'PCC'; + const parking = 'A-01-1'; + const itemFk = 1; + + const tx = await models.ItemShelving.beginTransaction({}); + const myOptions = {transaction: tx}; + const filter = {where: {shelvingFk: shelvingFkOut} + }; + try { + const itemShelvingBefore = await models.ItemShelving.findOne(filter, myOptions); + await itemShelvingBefore.updateAttributes({ + itemFk: itemFk + }); + const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking); + + expect(result).toBe(true); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +});