UNPKG

1.13 kBPlain TextView Raw
1import { CalendarDay, CalendarMonth, CalendarWeek } from "../classes";
2
3import { getWeeks } from "./getWeeks";
4
5const days1 = [
6 new CalendarDay(new Date(2023, 1, 12), new Date(2023, 1, 1)),
7 new CalendarDay(new Date(2023, 1, 13), new Date(2023, 1, 1))
8];
9const days2 = [
10 new CalendarDay(new Date(2023, 1, 13), new Date(2023, 1, 1)),
11 new CalendarDay(new Date(2023, 1, 14), new Date(2023, 1, 1))
12];
13const days3 = [
14 new CalendarDay(new Date(2023, 2, 12), new Date(2023, 2, 1)),
15 new CalendarDay(new Date(2023, 2, 13), new Date(2023, 2, 1))
16];
17const days4 = [
18 new CalendarDay(new Date(2023, 2, 13), new Date(2023, 2, 1)),
19 new CalendarDay(new Date(2023, 2, 14), new Date(2023, 2, 1))
20];
21const weeks1 = [new CalendarWeek(1, days1), new CalendarWeek(2, days2)];
22const weeks2 = [new CalendarWeek(3, days3), new CalendarWeek(4, days4)];
23const months = [
24 new CalendarMonth(days1[0].date, weeks1),
25 new CalendarMonth(days1[0].date, weeks2)
26];
27
28it("should return all the days belonging to the calendar by merging the days in the weeks for each month", () => {
29 expect(getWeeks(months)).toEqual([...weeks1, ...weeks2]);
30});