forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulti_month_test.js
45 lines (40 loc) · 1.35 KB
/
multi_month_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from "react";
import Calendar from "../src/calendar";
import Month from "../src/month";
import YearDropdown from "../src/year_dropdown";
import * as utils from "../src/date_utils";
import { shallow } from "enzyme";
describe("Multi month calendar", function() {
var dateFormat = "LLLL yyyy";
function getCalendar(extraProps) {
return shallow(
<Calendar
dateFormat={dateFormat}
onSelect={() => {}}
onClickOutside={() => {}}
hideCalendar={() => {}}
dropdownMode="scroll"
{...extraProps}
/>
);
}
it("should render multiple months if the months property is present", () => {
var calendar = getCalendar({ monthsShown: 2 });
var months = calendar.find(Month);
expect(months).to.have.length(2);
});
it("should render dropdown only on first month", () => {
var calendar = getCalendar({ monthsShown: 2, showYearDropdown: true });
var datepickers = calendar.find(YearDropdown);
expect(datepickers).to.have.length(1);
});
it("should render previous months", () => {
var calendar = getCalendar({ monthsShown: 2, showPreviousMonths: true });
var monthDate = calendar
.find(Month)
.first()
.prop("day");
var previousMonth = utils.subMonths(utils.newDate(), 1);
expect(utils.isSameMonth(previousMonth, monthDate)).to.be.true;
});
});