test buyUltimateFromInterval arreglado

This commit is contained in:
Javi Gallego 2019-11-14 13:40:53 +01:00
parent 136d1ef05f
commit 1301ea5962
1 changed files with 13 additions and 24 deletions

View File

@ -5,25 +5,14 @@ describe('buyUltimateFromInterval()', () => {
let today;
let future;
beforeAll(() => {
let date = new Date();
let month = `${date.getMonth() + 1}`;
let futureMonth = `${date.getMonth() + 2}`;
let day = date.getDate();
let year = date.getFullYear();
let futureYear = year;
let now = new Date();
now.setHours(0, 0, 0, 0);
today = now;
if (month.toString().length < 2) month = '0' + month;
if (futureMonth.toString().length < 2) futureMonth = '0' + futureMonth;
if (futureMonth.toString() == '13') {
futureMonth = '01';
futureYear + 1;
}
if (day.toString().length < 2) day = `0${day}`;
today = [year, month, day].join('-');
future = [futureYear, futureMonth, day].join('-');
let futureDate = new Date(now);
let futureMonth = now.getMonth() + 1;
futureDate.setMonth(futureMonth);
future = futureDate;
});
it(`should create a temporal table with it's data`, async() => {
@ -65,8 +54,8 @@ describe('buyUltimateFromInterval()', () => {
expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3);
expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5);
expect(buyUltimateFromIntervalTable[0].landed).toEqual(new Date(today));
expect(buyUltimateFromIntervalTable[1].landed).toEqual(new Date(today));
expect(buyUltimateFromIntervalTable[0].landed).toEqual(today);
expect(buyUltimateFromIntervalTable[1].landed).toEqual(today);
});
it(`should create a temporal table with it's data in which started value is assigned to ended`, async() => {
@ -101,8 +90,8 @@ describe('buyUltimateFromInterval()', () => {
expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3);
expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5);
expect(buyUltimateFromIntervalTable[0].landed).toEqual(new Date(today));
expect(buyUltimateFromIntervalTable[1].landed).toEqual(new Date(today));
expect(buyUltimateFromIntervalTable[0].landed).toEqual(today);
expect(buyUltimateFromIntervalTable[1].landed).toEqual(today);
});
it(`should create a temporal table with it's data in which ended value is a date in the future`, async() => {
@ -137,7 +126,7 @@ describe('buyUltimateFromInterval()', () => {
expect(buyUltimateFromIntervalTable[0].buyFk).toEqual(3);
expect(buyUltimateFromIntervalTable[1].buyFk).toEqual(5);
expect(buyUltimateFromIntervalTable[0].landed).toEqual(new Date(today));
expect(buyUltimateFromIntervalTable[1].landed).toEqual(new Date(today));
expect(buyUltimateFromIntervalTable[0].landed).toEqual(today);
expect(buyUltimateFromIntervalTable[1].landed).toEqual(today);
});
});