From 1301ea59628c8ceca825f60b3c2d6001afa9003c Mon Sep 17 00:00:00 2001 From: "LaptopVerdnatura\\Javi" Date: Thu, 14 Nov 2019 13:40:53 +0100 Subject: [PATCH] test buyUltimateFromInterval arreglado --- db/tests/vn/buyUltimateFromInterval.spec.js | 37 ++++++++------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/db/tests/vn/buyUltimateFromInterval.spec.js b/db/tests/vn/buyUltimateFromInterval.spec.js index b416b5cb2..b5e6970f7 100644 --- a/db/tests/vn/buyUltimateFromInterval.spec.js +++ b/db/tests/vn/buyUltimateFromInterval.spec.js @@ -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); }); });