2024-10-03 11:59:41 +03:00
|
|
|
/*
|
|
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2024-10-14 19:11:58 +03:00
|
|
|
import { fireEvent, render, screen } from "jest-matrix-react";
|
2024-10-03 11:59:41 +03:00
|
|
|
|
2024-10-15 16:57:26 +03:00
|
|
|
import BaseCard from "../../../../../src/components/views/right_panel/BaseCard.tsx";
|
|
|
|
import RightPanelStore from "../../../../../src/stores/right-panel/RightPanelStore.ts";
|
2024-10-03 11:59:41 +03:00
|
|
|
|
2024-10-15 16:57:26 +03:00
|
|
|
jest.mock("../../../../../src/stores/right-panel/RightPanelStore", () => ({
|
2024-10-03 11:59:41 +03:00
|
|
|
instance: {
|
|
|
|
popCard: jest.fn(),
|
|
|
|
roomPhaseHistory: [],
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe("<BaseCard />", () => {
|
|
|
|
it("should close when clicking X button", async () => {
|
|
|
|
const { asFragment } = render(
|
|
|
|
<BaseCard header="Heading text">
|
|
|
|
<div>Content</div>
|
|
|
|
</BaseCard>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(screen.getByRole("heading")).toHaveTextContent("Heading text");
|
|
|
|
expect(asFragment()).toMatchSnapshot();
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByTestId("base-card-close-button"));
|
|
|
|
expect(RightPanelStore.instance.popCard).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|