45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
|
|
/*
|
||
|
|
Copyright 2024 New Vector Ltd
|
||
|
|
|
||
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
|
you may not use this file except in compliance with the License.
|
||
|
|
You may obtain a copy of the License at
|
||
|
|
|
||
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
|
||
|
|
Unless required by applicable law or agreed to in writing, software
|
||
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
|
See the License for the specific language governing permissions and
|
||
|
|
limitations under the License.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { render, screen } from "@testing-library/react";
|
||
|
|
import { expect, test, vi } from "vitest";
|
||
|
|
import { Room } from "matrix-js-sdk/src/matrix";
|
||
|
|
import { axe } from "vitest-axe";
|
||
|
|
import { BrowserRouter } from "react-router-dom";
|
||
|
|
import userEvent from "@testing-library/user-event";
|
||
|
|
|
||
|
|
import { InviteModal } from "./InviteModal";
|
||
|
|
|
||
|
|
// Used by copy-to-clipboard
|
||
|
|
window.prompt = (): null => null;
|
||
|
|
|
||
|
|
test("InviteModal is accessible", async () => {
|
||
|
|
const user = userEvent.setup();
|
||
|
|
const room = {
|
||
|
|
roomId: "!a:example.org",
|
||
|
|
name: "Mission Control",
|
||
|
|
} as unknown as Room;
|
||
|
|
const onDismiss = vi.fn();
|
||
|
|
const { container } = render(
|
||
|
|
<InviteModal room={room} open={true} onDismiss={onDismiss} />,
|
||
|
|
{ wrapper: BrowserRouter },
|
||
|
|
);
|
||
|
|
|
||
|
|
expect(await axe(container)).toHaveNoViolations();
|
||
|
|
await user.click(screen.getByRole("button", { name: "action.copy_link" }));
|
||
|
|
expect(onDismiss).toBeCalled();
|
||
|
|
});
|