46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
|
|
const {models} = require('vn-loopback/server/server');
|
|
|
|
describe('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;
|
|
}
|
|
});
|
|
});
|