const {models} = require('vn-loopback/server/server'); describe('itemShelving getItemsByReviewOrder()', () => { it('should return empty because hoursToReview = 0', async() => { const shelving = 'NBB'; const parking = '700-01'; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; try { const config = await models.ProductionConfig.findOne(); await config.updateAttributes({ itemOrderReviewHours: null, }); const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, myOptions); expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return an item because you are trying parking a shelving and there is an older item', async() => { const shelving = 'NBB'; const parking = 'K-26-2'; const itemFk = 1000000; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; try { const config = await models.ProductionConfig.findOne(); await config.updateAttributes({ itemOrderReviewHours: 24, }); const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return an item because you are trying parking a shelving and there is an newer item', async() => { const shelving = 'NBB'; const parking = 'K-26-2'; const itemFk = 1000000; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; try { const config = await models.ProductionConfig.findOne(); await config.updateAttributes({ itemOrderReviewHours: 24, }); const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return a item list because you are trying parking a shelving and there is an newer item', async() => { const shelving = 'NCC'; const parking = 'K-26-2'; const itemFk = 1000000; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; try { const config = await models.ProductionConfig.findOne(); await config.updateAttributes({ itemOrderReviewHours: 24, }); const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return empty list because all order is correct', async() => { const shelving = 'NCC'; const parking = 'A-01-1'; const itemFk = 1000000; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; try { const config = await models.ProductionConfig.findOne(); await config.updateAttributes({ itemOrderReviewHours: 24, }); const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });