-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccordion.test.tsx
More file actions
51 lines (43 loc) · 1.27 KB
/
Accordion.test.tsx
File metadata and controls
51 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) 2019-2026 by Brockmann Consult Development team
* Permissions are hereby granted under the terms of the MIT License:
* https://opensource.org/licenses/MIT.
*/
import { render, screen, fireEvent } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Accordion } from "./Accordion";
import { createChangeHandler } from "@/plugins/mui/common.test";
describe("Accordion", () => {
it("should render the Accordion component", () => {
render(
<Accordion
id="acc"
type="Accordion"
label="My Accordion"
onChange={() => {}}
/>,
);
expect(screen.getByText("My Accordion")).not.toBeUndefined();
});
it("should fire 'expanded' property", () => {
const { recordedEvents, onChange } = createChangeHandler();
render(
<Accordion
id="acc"
type="Accordion"
expanded={false}
label="My Accordion"
onChange={onChange}
></Accordion>,
);
// MUI Summary renders a button element
fireEvent.click(screen.getByRole("button"));
expect(recordedEvents.length).toEqual(1);
expect(recordedEvents[0]).toEqual({
componentType: "Accordion",
id: "acc",
property: "expanded",
value: true,
});
});
});