refs #6964 feat:advice for olderItem
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Sergio De la torre 2024-03-22 11:42:19 +01:00
parent 4dca49360e
commit 976c5b7ba8
1 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,45 @@
const {models} = require('vn-loopback/server/server');
fdescribe('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;
}
});
});