2024-03-22 10:42:19 +00:00
|
|
|
|
|
|
|
const {models} = require('vn-loopback/server/server');
|
|
|
|
|
2024-03-22 12:04:16 +00:00
|
|
|
describe('itemShelving hasOlder()', () => {
|
2024-03-22 10:42:19 +00:00
|
|
|
it('should return false because there are not older items', async() => {
|
|
|
|
const shelvingFkIn = 'GVC';
|
|
|
|
const shelvingFkOut = 'HEJ';
|
2024-03-25 07:20:08 +00:00
|
|
|
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, null, shelvingFkOut);
|
2024-03-22 10:42:19 +00:00
|
|
|
|
|
|
|
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
|
2024-03-27 06:09:18 +00:00
|
|
|
}, myOptions);
|
2024-03-25 07:20:08 +00:00
|
|
|
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking, null, null, myOptions);
|
2024-03-22 10:42:19 +00:00
|
|
|
|
|
|
|
expect(result).toBe(true);
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|