mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-15 00:04:59 +08:00
Test StarRating
This commit is contained in:
parent
e8278b4ed2
commit
d12a01b1c4
29
src/input/StarRating.test.tsx
Normal file
29
src/input/StarRating.test.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { test, expect, vi } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { axe } from "vitest-axe";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
import { StarRatingInput } from "./StarRatingInput";
|
||||
|
||||
test("StarRatingInput is accessible", async () => {
|
||||
const user = userEvent.setup();
|
||||
const onChange = vi.fn();
|
||||
const { container } = render(
|
||||
<StarRatingInput starCount={5} onChange={onChange} />,
|
||||
);
|
||||
expect(await axe(container)).toHaveNoViolations();
|
||||
// Change the rating to 4 stars
|
||||
await user.click(
|
||||
(
|
||||
await screen.findAllByRole("radio", { name: "star_rating_input_label" })
|
||||
)[3],
|
||||
);
|
||||
expect(onChange).toBeCalledWith(4);
|
||||
});
|
Loading…
Reference in New Issue
Block a user