UNPKG

1.27 kBPlain TextView Raw
1import { dateLib } from "react-day-picker";
2
3import { getDisplayMonths } from "./getDisplayMonths";
4
5describe("getDisplayMonths", () => {
6 it("should return the months to display in the calendar", () => {
7 const firstMonth = new Date(2020, 0);
8 const expectedResult = [new Date(2020, 0)];
9 const result = getDisplayMonths(firstMonth, undefined, {}, dateLib);
10 expect(result).toEqual(expectedResult);
11 });
12
13 it("should return the months to display in the calendar when the number of months is greater than 1", () => {
14 const firstMonth = new Date(2020, 0);
15 const expectedResult = [
16 new Date(2020, 0),
17 new Date(2020, 1),
18 new Date(2020, 2)
19 ];
20 const result = getDisplayMonths(
21 firstMonth,
22 undefined,
23 {
24 numberOfMonths: 3
25 },
26 dateLib
27 );
28 expect(result).toEqual(expectedResult);
29 });
30
31 it("should return the months to display in the calendar when passing a max date", () => {
32 const firstMonth = new Date(2020, 0);
33 const expectedResult = [new Date(2020, 0), new Date(2020, 1)];
34 const result = getDisplayMonths(
35 firstMonth,
36 new Date(2020, 1, 10),
37 {
38 numberOfMonths: 3
39 },
40 dateLib
41 );
42 expect(result).toEqual(expectedResult);
43 });
44});