import * as React from "react";
import {
render,
screen,
fireEvent,
cleanup,
getByTestId,
} from "@testing-library/react";
import DropDownCollapse from "./DropDownCollapse";
describe(" Rendering >", () => {
it(`The component should render in the dom`, () => {
render();
expect(screen.queryByTestId("DropDownCollapse")).toBeTruthy();
});
it(`Should render a caption in the dom that matches the text prop`, () => {
const text = "Drop down Collapse Test";
const { debug } = render();
expect(screen.queryByText(text)).toBeTruthy();
});
it(`Should not show children if the isExpanded prop is false`, () => {
const content = "Drop down children content";
const { debug } = render(
{content}
);
// console.log(screen.queryByText(content));
expect(screen.queryByText(content)).toBe(null);
});
it(`Should toggle between collapsed and expanded when clicked`, () => {
const content = "Drop down children content";
const { debug } = render(
{content}
);
expect(screen.queryByTestId("DropDownCollapse-Children")).toBe(null);
fireEvent.click(screen.getByTestId("DropDownCollapse"));
expect(screen.queryByTestId("DropDownCollapse-Children")).toBeTruthy();
});
});
describe(" Events >", () => {
it(`Should trigger the onChange() event when the dropdown is changed`, () => {
const onChange = jest.fn();
const { debug } = render(
);
fireEvent.click(screen.getByTestId("DropDownCollapse"));
expect(onChange).toHaveBeenCalled();
});
});
describe(" Hooks >", () => {
test.skip(`Should trigger the _onDropDownCollapseRender_ plugin hook when the DropDownCollapse is being rendered`, () => {});
test.skip(`Should trigger the _onDropDownCollapseChange_ plugin hook when the dropdown is changed`, () => {});
});