Skip to content

Commit

Permalink
Fix errors in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Oct 27, 2018
1 parent 247c909 commit 812f095
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CenturyView/__tests__/Decade.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/DecadeView/__tests__/Year.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/MonthView/__tests__/Day.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions src/YearView/__tests__/Month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
Expand Down
12 changes: 12 additions & 0 deletions src/shared/dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down

0 comments on commit 812f095

Please sign in to comment.