Debian Codegraph @

install/freeipa-webui/src/components/layouts/ToolbarLayout/ToolbarLayout.test.tsx

raw
1 import React from "react";
2 import { render, screen } from "@testing-library/react";
3 import { expect, test } from "vitest";
4 // Component
5 import ToolbarLayout from "./ToolbarLayout";
6
7 test("should display the ToolbarLayout with required props", () => {
8 const { container } = render(
9 <ToolbarLayout
10 toolbarItems={[
11 {
12 key: 1,
13 element: <div>Test Toolbar Element</div>,
14 },
15 ]}
16 />
17 );
18 expect(screen.getByText("Test Toolbar Element")).toBeInTheDocument();
19 expect(container.querySelector('[id="1"]')).toBeInTheDocument();
20 });
21
22 test("should display the ToolbarLayout with the proper amount of children", () => {
23 render(
24 <ToolbarLayout
25 toolbarItems={[
26 {
27 key: 1,
28 element: <div>Test Toolbar Item</div>,
29 },
30 {
31 key: 2,
32 element: <div>Test Toolbar Item</div>,
33 },
34 {
35 key: 3,
36 element: <div>Test Toolbar Item</div>,
37 },
38 ]}
39 />
40 );
41 expect(screen.getAllByText(/Test Toolbar Item/)).toHaveLength(3);
42 });