test: refs #6321 getSimilar.spec.js
This commit is contained in:
parent
c4e64db9b9
commit
9390c0efed
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getSimilar', {
|
||||
Self.remoteMethod('getSimilar', {
|
||||
description: 'Returns list of items with similar item requested',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Item get similar', () => {
|
||||
let options;
|
||||
let tx;
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeEach(async() => {
|
||||
tx = await models.Item.beginTransaction({});
|
||||
options = {transaction: tx};
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
if (tx)
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should return similar items', async() => {
|
||||
const filter = {
|
||||
itemFk: 88, sales: 43,
|
||||
where: {
|
||||
'scopeDays': '2',
|
||||
'showType': true,
|
||||
'alertLevelCode': 'FREE',
|
||||
'date': '2001-01-01T11:00:00.000Z',
|
||||
'warehouseFk': 1
|
||||
}
|
||||
};
|
||||
const result = await models.Item.getSimilar(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should return empty array is if not exists', async() => {
|
||||
const filter = {
|
||||
itemFk: 88, sales: 43,
|
||||
where: {
|
||||
'scopeDays': '2',
|
||||
'showType': true,
|
||||
'alertLevelCode': 'FREE',
|
||||
'date': '2001-01-01T11:00:00.000Z',
|
||||
'warehouseFk': 60
|
||||
}
|
||||
};
|
||||
const result = await models.Item.getSimilar(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(0);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue