salix/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-06-07 14:29:51 +00:00
const {models} = require('vn-loopback/server/server');
describe('itemShelving getListItemNewer()', () => {
2024-06-18 08:08:40 +00:00
it('should return true because there is an older item', async() => {
2024-06-07 14:29:51 +00:00
const shelving = 'NCC';
const parking = 'A-47-1';
2024-06-18 08:08:40 +00:00
const sectorCamHighCode = 'CAMARA SECTOR D';
const sectorCamCode = 'NAVE ALGEMESI';
const sectorCamCodeHighId = 1;
const sectorCamCodeId = 9991;
2024-06-07 14:29:51 +00:00
const tx = await models.Sector.beginTransaction({});
const myOptions = {transaction: tx};
try {
2024-06-18 08:08:40 +00:00
const sectorHighCam = await models.Sector.findById(sectorCamCodeHighId, null, myOptions);
await sectorHighCam.updateAttributes({
code: sectorCamHighCode
});
2024-06-07 14:29:51 +00:00
2024-06-18 08:08:40 +00:00
const sectorCam = await models.Sector.findById(sectorCamCodeId, null, myOptions);
await sectorCam.updateAttributes({
2024-06-07 14:29:51 +00:00
code: sectorCamCode
2024-06-18 08:08:40 +00:00
});
2024-06-07 14:29:51 +00:00
2024-06-18 08:08:40 +00:00
const config = await models.ProductionConfig.findOne();
await config.updateAttributes({
sectorToCode: sectorCamHighCode,
sectorFromCode: sectorCamCode
});
2024-06-07 14:29:51 +00:00
const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions);
expect(result.length).toEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});