1
0
mirror of https://github.com/element-hq/element-web.git synced 2025-08-09 14:42:51 +03:00
Files
element-web/test/unit-tests/components/views/dialogs/ConfirmRedactDialog-test.tsx
renovate[bot] 4a381c2a10 Update all non-major dependencies (#29194)
* Update all non-major dependencies

* Delint

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Prettier

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2025-02-05 13:25:06 +00:00

60 lines
2.1 KiB
TypeScript

/*
Copyright 2024 New Vector Ltd.
Copyright 2022 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { type MatrixClient, type MatrixEvent } from "matrix-js-sdk/src/matrix";
import { screen, act } from "jest-matrix-react";
import userEvent from "@testing-library/user-event";
import { flushPromises, mkEvent, stubClient } from "../../../../test-utils";
import { createRedactEventDialog } from "../../../../../src/components/views/dialogs/ConfirmRedactDialog";
describe("ConfirmRedactDialog", () => {
const roomId = "!room:example.com";
let client: MatrixClient;
let mxEvent: MatrixEvent;
const confirmDeleteVoiceBroadcastStartedEvent = async () => {
act(() => createRedactEventDialog({ mxEvent }));
// double-flush promises required for the dialog to show up
await flushPromises();
await flushPromises();
await userEvent.click(await screen.findByTestId("dialog-primary-button"));
};
beforeEach(() => {
client = stubClient();
});
it("should raise an error for an event without ID", async () => {
mxEvent = mkEvent({
event: true,
type: "m.room.message",
room: roomId,
content: {},
user: client.getSafeUserId(),
});
jest.spyOn(mxEvent, "getId").mockReturnValue(undefined);
await expect(confirmDeleteVoiceBroadcastStartedEvent()).rejects.toThrow("cannot redact event without ID");
});
it("should raise an error for an event without room-ID", async () => {
mxEvent = mkEvent({
event: true,
type: "m.room.message",
room: roomId,
content: {},
user: client.getSafeUserId(),
});
jest.spyOn(mxEvent, "getRoomId").mockReturnValue(undefined);
await expect(confirmDeleteVoiceBroadcastStartedEvent()).rejects.toThrow(
`cannot redact event ${mxEvent.getId()} without room ID`,
);
});
});