2018-08-16 10:10:56 +00:00
|
|
|
const app = require(`${servicesDir}/item/server/server`);
|
|
|
|
|
|
|
|
describe('item getLastEntries()', () => {
|
2018-11-07 07:38:06 +00:00
|
|
|
it('should return one entry for a given item', async () => {
|
2018-08-16 10:10:56 +00:00
|
|
|
let date = new Date();
|
|
|
|
let filter = {where: {itemFk: 1, date: date}};
|
|
|
|
let result = await app.models.Item.getLastEntries(filter);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(1);
|
|
|
|
});
|
|
|
|
|
2018-11-07 07:38:06 +00:00
|
|
|
it('should return three entries for a given item', async () => {
|
2018-08-16 10:10:56 +00:00
|
|
|
let date = new Date();
|
|
|
|
date.setMonth(date.getMonth() - 2);
|
|
|
|
let filter = {where: {itemFk: 1, date: date}};
|
|
|
|
let result = await app.models.Item.getLastEntries(filter);
|
|
|
|
|
|
|
|
expect(result.length).toEqual(3);
|
|
|
|
});
|
|
|
|
});
|