Skip to content

Commit

Permalink
fix(react-components): update viewportAdapter tests for month and min…
Browse files Browse the repository at this point in the history
…utes
  • Loading branch information
ssjagad committed Nov 1, 2023
1 parent fb2caed commit a269626
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ describe('getViewportStartOnBackwardRelative', () => {
type: 'relative',
});

expect(currentDate.getTime() - newDate.getTime()).toEqual(300000);
const result = currentDate.getTime() - newDate.getTime();
expect(result).toBeGreaterThanOrEqual(299999);
expect(result).toBeLessThanOrEqual(300000);

currentDate = new Date();
newDate = getViewportStartOnBackwardRelative({
Expand Down Expand Up @@ -193,6 +195,13 @@ describe('getViewportStartOnBackwardRelative', () => {
unit: 'month',
type: 'relative',
});
expect(currentDate.getTime() - newDate.getTime()).toEqual(2678400000);

if ([0, 1, 3, 5, 6, 7, 8, 10].includes(currentDate.getMonth())) {
expect(currentDate.getTime() - newDate.getTime()).toEqual(2678400000); //previous month is 31 days
} else if (currentDate.getMonth() === 2) {
expect(currentDate.getTime() - newDate.getTime()).toEqual(2419200000 || 2505600000); //previous month is february
} else {
expect(currentDate.getTime() - newDate.getTime()).toEqual(2592000000); //previous month is 30 days
}
});
});

0 comments on commit a269626

Please sign in to comment.