forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek_number_test.js
31 lines (28 loc) · 998 Bytes
/
week_number_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
import React from "react";
import WeekNumber from "../src/week_number";
import { shallow } from "enzyme";
import sinon from "sinon";
function renderWeekNumber(weekNumber, props = {}) {
return shallow(<WeekNumber weekNumber={weekNumber} {...props} />);
}
describe("WeekNumber", () => {
let shallowWeekNumber;
describe("rendering", () => {
it("should render the specified Week Number", () => {
const weekNumber = 1;
shallowWeekNumber = renderWeekNumber(weekNumber);
expect(
shallowWeekNumber.hasClass("react-datepicker__week-number")
).to.equal(true);
expect(shallowWeekNumber.text()).to.equal(weekNumber + "");
});
it("should call the onClick function if it is defined", () => {
const onClick = sinon.spy();
shallowWeekNumber = shallow(
<WeekNumber weekNumber={1} onClick={onClick} />
);
shallowWeekNumber.instance().handleClick({});
expect(onClick).to.have.property("callCount", 1);
});
});
});