Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 13c6c4d

Browse files
committed
Add a test in EventTile-test.tsx
1 parent 2f34023 commit 13c6c4d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/components/views/rooms/EventTile-test.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import DMRoomMap from "../../../../src/utils/DMRoomMap";
3232
import dis from "../../../../src/dispatcher/dispatcher";
3333
import { Action } from "../../../../src/dispatcher/actions";
3434
import { IRoomState } from "../../../../src/components/structures/RoomView";
35+
import PinningUtils from "../../../../src/utils/PinningUtils.ts";
3536

3637
describe("EventTile", () => {
3738
const ROOM_ID = "!roomId:example.org";
@@ -91,6 +92,10 @@ describe("EventTile", () => {
9192
});
9293
});
9394

95+
afterEach(() => {
96+
jest.spyOn(PinningUtils, "isPinned").mockReturnValue(false);
97+
});
98+
9499
describe("EventTile thread summary", () => {
95100
beforeEach(() => {
96101
jest.spyOn(client, "supportsThreads").mockReturnValue(true);
@@ -129,6 +134,26 @@ describe("EventTile", () => {
129134

130135
await waitFor(() => expect(screen.queryByTestId("thread-summary")).toBeNull());
131136
});
137+
138+
it("should display the pinned message badge", async () => {
139+
jest.spyOn(PinningUtils, "isPinned").mockReturnValue(true);
140+
141+
const { rootEvent } = mkThread({
142+
room,
143+
client,
144+
authorId: "@alice:example.org",
145+
participantUserIds: ["@alice:example.org"],
146+
length: 2, // root + 1 answer
147+
});
148+
getComponent(
149+
{
150+
mxEvent: rootEvent,
151+
},
152+
TimelineRenderingType.Room,
153+
);
154+
155+
expect(screen.getByText("Pinned message")).toBeInTheDocument();
156+
});
132157
});
133158

134159
describe("EventTile renderingType: ThreadsList", () => {
@@ -510,4 +535,10 @@ describe("EventTile", () => {
510535
});
511536
});
512537
});
538+
539+
test("it should render a pinned message badge", async () => {
540+
jest.spyOn(PinningUtils, "isPinned").mockReturnValue(true);
541+
getComponent();
542+
expect(screen.getByText("Pinned message")).toBeInTheDocument();
543+
});
513544
});

0 commit comments

Comments
 (0)