forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexclude_times_test.js
37 lines (32 loc) · 978 Bytes
/
exclude_times_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
import React from "react";
import { mount } from "enzyme";
import { setTime, cloneDate, newDate } from "../src/date_utils";
import DatePicker from "../src/index.jsx";
function cloneDateWithTime(date, time) {
return setTime(cloneDate(date), time);
}
describe("DatePicker", () => {
let sandbox;
beforeEach(() => {
sandbox = sinon.sandbox.create();
});
afterEach(() => {
sandbox.restore();
});
it("should disable times specified in excludeTimes props", () => {
var now = newDate();
var datePicker = mount(
<DatePicker
showTimeSelect
excludeTimes={[
cloneDateWithTime(now, { hours: 17, minutes: 0 }),
cloneDateWithTime(now, { hours: 18, minutes: 30 }),
cloneDateWithTime(now, { hours: 19, minutes: 30 }),
cloneDateWithTime(now, { hours: 17, minutes: 30 })
]}
/>
);
expect(datePicker.find(".react-datepicker__time-list-item--disabled")).to
.exist;
});
});