1 import isLastWeek from './isLastWeek';
3 describe('isLastWeek', () => {
5 jest.useFakeTimers().setSystemTime(new Date('2023-03-27T20:00:00'));
12 it('should return true if the date is in the last week', () => {
13 const date = new Date(2023, 2, 20); // March 20, 2023 is in the last week
14 expect(isLastWeek(date)).toBe(true);
17 it('should return false if the date is not in the last week', () => {
18 const date = new Date(2022, 2, 27); // March 27, 2022 is not in the last week
19 expect(isLastWeek(date)).toBe(false);
22 it('should handle weekStartsOn option correctly', () => {
23 const date = new Date(2023, 2, 20); // March 20, 2023 is in the last week, regardless of weekStartsOn value
24 // With Monday is the start of the week
25 expect(isLastWeek(date, { weekStartsOn: 1 })).toBe(true);
28 it('should return true if the date is in the last week and given as a timestamp', () => {
29 const timestamp = new Date(2023, 2, 20).getTime(); // March 20, 2023 is in the last week
30 expect(isLastWeek(timestamp)).toBe(true);