forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_time_test.js
55 lines (44 loc) · 1.76 KB
/
show_time_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
46
47
48
49
50
51
52
53
54
55
import React from "react";
import { mount } from "enzyme";
import DatePicker from "../src/index.jsx";
import TimeComponent from "../src/time";
describe("DatePicker", () => {
let sandbox;
beforeEach(() => {
sandbox = sinon.sandbox.create();
});
afterEach(() => {
sandbox.restore();
});
it("should show time component when showTimeSelect prop is present", () => {
var datePicker = mount(<DatePicker showTimeSelect />);
var timeComponent = datePicker.find(TimeComponent);
expect(timeComponent).to.exist;
});
it("should have custom time caption", () => {
const timeComponent = mount(<TimeComponent timeCaption="Custom time" />);
const caption = timeComponent.find(".react-datepicker-time__header");
expect(caption.text()).to.equal("Custom time");
});
describe("Time Select Only", () => {
var datePicker = mount(
<DatePicker showTimeSelect showTimeSelectOnly todayButton="Today" />
);
it("should not show month container when showTimeSelectOnly prop is present", () => {
var elem = datePicker.find(".react-datepicker__month-container");
expect(elem).to.have.length(0);
});
it("should not show previous month button when showTimeSelectOnly prop is present", () => {
var elem = datePicker.find(".react-datepicker__navigation--previous");
expect(elem).to.have.length(0);
});
it("should not show next month button when showTimeSelectOnly prop is present", () => {
var elem = datePicker.find(".react-datepicker__navigation--next");
expect(elem).to.have.length(0);
});
it("should not show today button when showTimeSelectOnly prop is present", () => {
var elem = datePicker.find(".react-datepicker__today-button");
expect(elem).to.have.length(0);
});
});
});