UNPKG

1.14 kBPlain TextView Raw
1import { CalendarDay, CalendarWeek, CalendarMonth } from "../classes";
2
3import { getDays } from "./getDays";
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(getDays(months)).toEqual([...days1, ...days2, ...days3, ...days4]);
30});