const {models} = require('vn-loopback/server/server'); describe('itemShelving getListItemNewer()', () => { fit('should return true because there is an older item', async() => { const shelving = 'NCC'; const parking = 'A-47-1'; const sectorCam = 1; const sectorCamCode = 'CAMARA SECTOR D'; const sectorCamHigh = 9991; const sectorCamHighCode = 'NAVE ALGEMESI'; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; const filter = {where: {id: sectorCam}}; const filterHigh = {where: {id: sectorCamHigh}}; try { const sectorCamBefore = await models.Sector.findOne(filter, myOptions); await sectorCamBefore.updateAttributes({ code: sectorCamCode }, myOptions); const sectorCamHighBefore = await models.Sector.findOne(filterHigh, myOptions); await sectorCamHighBefore.updateAttributes({ code: sectorCamHighCode }, myOptions); const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions); expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });