Add tests for ReadReceiptGroup.tsx
This commit is contained in:
parent
a6907a033e
commit
04741ae6a6
3 changed files with 138 additions and 2 deletions
|
@ -14,8 +14,18 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { determineAvatarPosition, readReceiptTooltip } from "../../../../src/components/views/rooms/ReadReceiptGroup";
|
||||
import React from "react";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
import {
|
||||
determineAvatarPosition,
|
||||
ReadReceiptPerson,
|
||||
readReceiptTooltip,
|
||||
} from "../../../../src/components/views/rooms/ReadReceiptGroup";
|
||||
import * as languageHandler from "../../../../src/languageHandler";
|
||||
import { stubClient } from "../../../test-utils";
|
||||
|
||||
describe("ReadReceiptGroup", () => {
|
||||
describe("TooltipText", () => {
|
||||
|
@ -79,4 +89,35 @@ describe("ReadReceiptGroup", () => {
|
|||
expect(determineAvatarPosition(5, 4)).toEqual({ hidden: true, position: 0 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("<ReadReceiptPerson />", () => {
|
||||
stubClient();
|
||||
|
||||
const ROOM_ID = "roomId";
|
||||
const USER_ID = "@alice:example.org";
|
||||
|
||||
const member = new RoomMember(ROOM_ID, USER_ID);
|
||||
member.rawDisplayName = "Alice";
|
||||
member.getMxcAvatarUrl = () => "http://placekitten.com/400/400";
|
||||
|
||||
const renderReadReceipt = () => {
|
||||
const currentDate = new Date(2024, 4, 15).getTime();
|
||||
return render(<ReadReceiptPerson userId={USER_ID} roomMember={member} ts={currentDate} />);
|
||||
};
|
||||
|
||||
it("should render", () => {
|
||||
const { container } = renderReadReceipt();
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should display a tooltip", async () => {
|
||||
renderReadReceipt();
|
||||
|
||||
await userEvent.hover(screen.getByRole("menuitem"));
|
||||
await waitFor(() => {
|
||||
const tooltip = screen.getByRole("tooltip", { name: member.rawDisplayName });
|
||||
expect(tooltip).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue