Updated unit test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-09-01 07:38:03 +02:00
parent 8aa9918d84
commit 0a542a2057
1 changed files with 10 additions and 8 deletions

View File

@ -1,21 +1,23 @@
const app = require('vn-loopback/server/server');
describe('item lastEntriesFilter()', () => {
const minDate = new Date(value);
minHour.setHours(0, 0, 0, 0);
const maxDate = new Date(value);
maxHour.setHours(23, 59, 59, 59);
it('should return one entry for a given item', async() => {
let date = new Date();
let filter = {where: {itemFk: 1, date: date}};
let result = await app.models.Item.lastEntriesFilter(filter);
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
const result = await app.models.Item.lastEntriesFilter(filter);
expect(result.length).toEqual(1);
});
it('should return five entries for a given item', async() => {
let date = new Date();
minDate.setMonth(minDate.getMonth() - 2, 1);
date.setMonth(date.getMonth() - 2, 1);
let filter = {where: {itemFk: 1, date: date}};
let result = await app.models.Item.lastEntriesFilter(filter);
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
const result = await app.models.Item.lastEntriesFilter(filter);
expect(result.length).toEqual(5);
});