Skip to content

Commit

Permalink
added tests for renderChildren method
Browse files Browse the repository at this point in the history
  • Loading branch information
shreekeshmurkar committed Jun 6, 2022
1 parent 945bd81 commit ee5adca
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/calendar_test.js
Expand Up @@ -1712,4 +1712,33 @@ describe("Calendar", function () {
expect(onKeyDownSpy.calledOnce).to.be.true;
});
});

describe("renderChildren", () => {
const renderCalendar = (props) =>
mount(
<Calendar
dateFormat={dateFormat}
onSelect={() => {}}
onClickOutside={() => {}}
hideCalendar={() => {}}
dropdownMode="scroll"
{...props}
/>
);
const childrenContainerSelector = ".react-datepicker__children-container";

it("should render children components", function () {
const calendar = renderCalendar({
children: <div>This is a child component for test.</div>,
});
const childrenContainer = calendar.find(childrenContainerSelector);
expect(childrenContainer).to.have.length(1);
});

it("should not render children components", function () {
const calendar = renderCalendar();
const childrenContainer = calendar.find(childrenContainerSelector);
expect(childrenContainer).to.have.length(0);
});
});
});

0 comments on commit ee5adca

Please sign in to comment.