From 812f09559829aa8cbbfa7bc983b50ca0e65cf390 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Sat, 27 Oct 2018 21:25:34 +0200 Subject: [PATCH] Fix errors in unit tests --- src/CenturyView/__tests__/Decade.jsx | 1 + src/DecadeView/__tests__/Year.jsx | 1 + src/MonthView/__tests__/Day.jsx | 1 + src/YearView/__tests__/Month.jsx | 1 + src/shared/dates.js | 12 ++++++++++++ 5 files changed, 16 insertions(+) diff --git a/src/CenturyView/__tests__/Decade.jsx b/src/CenturyView/__tests__/Decade.jsx index c070e91a..61f5aaa0 100644 --- a/src/CenturyView/__tests__/Decade.jsx +++ b/src/CenturyView/__tests__/Decade.jsx @@ -6,6 +6,7 @@ import Decade from '../Decade'; /* eslint-disable comma-dangle, jsx-a11y/mouse-events-have-key-events */ const tileProps = { + activeStartDate: new Date(2018, 0, 1), classes: ['react-calendar__tile'], date: new Date(2011, 0, 1), point: 2011, diff --git a/src/DecadeView/__tests__/Year.jsx b/src/DecadeView/__tests__/Year.jsx index f9956941..e7a78318 100644 --- a/src/DecadeView/__tests__/Year.jsx +++ b/src/DecadeView/__tests__/Year.jsx @@ -6,6 +6,7 @@ import Year from '../Year'; /* eslint-disable comma-dangle, jsx-a11y/mouse-events-have-key-events */ const tileProps = { + activeStartDate: new Date(2018, 0, 1), classes: ['react-calendar__tile'], date: new Date(2018, 0, 1), point: 2018, diff --git a/src/MonthView/__tests__/Day.jsx b/src/MonthView/__tests__/Day.jsx index dcaddf05..85b5a822 100644 --- a/src/MonthView/__tests__/Day.jsx +++ b/src/MonthView/__tests__/Day.jsx @@ -6,6 +6,7 @@ import Day from '../Day'; /* eslint-disable comma-dangle, jsx-a11y/mouse-events-have-key-events */ const tileProps = { + activeStartDate: new Date(2018, 0, 1), classes: ['react-calendar__tile'], currentMonthIndex: 0, date: new Date(2018, 0, 1), diff --git a/src/YearView/__tests__/Month.jsx b/src/YearView/__tests__/Month.jsx index 1d791792..e0a4aaf1 100644 --- a/src/YearView/__tests__/Month.jsx +++ b/src/YearView/__tests__/Month.jsx @@ -6,6 +6,7 @@ import Month from '../Month'; /* eslint-disable comma-dangle, jsx-a11y/mouse-events-have-key-events */ const tileProps = { + activeStartDate: new Date(2018, 0, 1), classes: ['react-calendar__tile'], date: new Date(2018, 0, 1), }; diff --git a/src/shared/dates.js b/src/shared/dates.js index 4391b23d..ee657649 100644 --- a/src/shared/dates.js +++ b/src/shared/dates.js @@ -440,6 +440,18 @@ export const getRange = (rangeType, date) => { */ export const getValueRange = (rangeType, date1, date2) => { const rawNextValue = [date1, date2].sort((a, b) => a.getTime() > b.getTime()); + console.log( + 'Original sorted values', + rawNextValue, + 'their values', + rawNextValue.map(e => e.getTime()), + 'their sorted values', + rawNextValue.map(e => e.getTime()).sort(), + 'their mapped sorted values', + rawNextValue.map(e => e.getTime()).sort().map(e => new Date(e)), + 'js sanity check', + [new Date(2018, 6, 1), new Date(2018, 0, 1)].sort((a, b) => a.getTime() > b.getTime()), + ); return [ getBegin(rangeType, rawNextValue[0]), getEnd(rangeType, rawNextValue[1]),