Skip to content

Commit cf3bdbd

Browse files
authored
Fix Read Receipt Test (#28719)
* Update test snapshot as the date formatting appears to have gained a comma, and somehow got through the merge tests on the dependency bump. * Actually this was the problem
1 parent ba98c20 commit cf3bdbd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import React, { ComponentProps } from "react";
1010
import { render, screen, waitFor } from "jest-matrix-react";
1111
import { RoomMember } from "matrix-js-sdk/src/matrix";
1212
import userEvent from "@testing-library/user-event";
13+
import { mocked } from "jest-mock";
1314

1415
import {
1516
determineAvatarPosition,
@@ -20,6 +21,9 @@ import * as languageHandler from "../../../../../src/languageHandler";
2021
import { stubClient } from "../../../../test-utils";
2122
import dispatcher from "../../../../../src/dispatcher/dispatcher";
2223
import { Action } from "../../../../../src/dispatcher/actions";
24+
import { formatDate } from "../../../../../src/DateUtils";
25+
26+
jest.mock("../../../../../src/DateUtils");
2327

2428
describe("ReadReceiptGroup", () => {
2529
describe("TooltipText", () => {
@@ -87,6 +91,10 @@ describe("ReadReceiptGroup", () => {
8791
describe("<ReadReceiptPerson />", () => {
8892
stubClient();
8993

94+
// We pick a fixed time but this can still vary depending on the locale
95+
// the tests are run in. We are not testing date formatting here, so stub it out.
96+
mocked(formatDate).mockReturnValue("==MOCK FORMATTED DATE==");
97+
9098
const ROOM_ID = "roomId";
9199
const USER_ID = "@alice:example.org";
92100

test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ exports[`ReadReceiptGroup <ReadReceiptPerson /> should render 1`] = `
8484
<p
8585
class="mx_ReadReceiptGroup_secondary"
8686
>
87-
Wed, 15 May, 0:00
87+
==MOCK FORMATTED DATE==
8888
</p>
8989
</div>
9090
</div>

0 commit comments

Comments
 (0)