mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import type { RenderResult } from "@testing-library/react";
|
|
import { render } from "@testing-library/react";
|
|
import React from "react";
|
|
import { DrawerParamToggler } from "./drawer-param-toggler";
|
|
|
|
describe("<DrawerParamToggler />", () => {
|
|
let result: RenderResult;
|
|
|
|
beforeEach(() => {
|
|
result = render((
|
|
<DrawerParamToggler
|
|
label="Foo"
|
|
>
|
|
<div data-testid="drawer-child"></div>
|
|
</DrawerParamToggler>
|
|
));
|
|
});
|
|
|
|
it("renders", () => {
|
|
expect(result.baseElement).toMatchSnapshot();
|
|
});
|
|
|
|
it("does not render children by default", () => {
|
|
expect(result.queryByTestId("drawer-child")).toBeNull();
|
|
});
|
|
|
|
describe("after clicking the toggle", () => {
|
|
beforeEach(() => {
|
|
result.getByTestId("drawer-param-toggler").click();
|
|
});
|
|
|
|
it("renders", () => {
|
|
expect(result.baseElement).toMatchSnapshot();
|
|
});
|
|
|
|
it("renders children", () => {
|
|
expect(result.queryByTestId("drawer-child")).not.toBeNull();
|
|
});
|
|
|
|
describe("after clicking the toggle again", () => {
|
|
beforeEach(() => {
|
|
result.getByTestId("drawer-param-toggler").click();
|
|
});
|
|
|
|
it("renders", () => {
|
|
expect(result.baseElement).toMatchSnapshot();
|
|
});
|
|
|
|
it("does not children", () => {
|
|
expect(result.queryByTestId("drawer-child")).toBeNull();
|
|
});
|
|
});
|
|
});
|
|
});
|