i'm newbie on react-testing-library
i'm trying to test my component which inside have conditional rendering.
is my Component:
const ComponentA = () => {
const [isActive, setIsActive] = (false);
const toggle = () => {
setIsActive(!isActive)
}
return (
<>
<div>
<h1 onClick={toggle}>Title</h1>
</div>
{isActive && (<div className="some"><h4>SubTitle</h4></div>)}
</>
)
}
and its my test:
import React from "react";
import { ComponentA } from "./";
import { render } from "@testing-library/react";
it("renders without crashing", async () => {
const wrapper = render(
<ComponentA />
);
expect(wrapper).toMatchSnapshot();
wrapper.unmount();
});
here is test passed but i wan't to test isActive case. So if is active true div with className some will render or not eg.
how i can do that?