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

Commit 6ce4cc8

Browse files
committed
Add tests for redaction
1 parent 54f9723 commit 6ce4cc8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

test/components/views/right_panel/PinnedMessagesCard-test.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { mocked, MockedObject } from "jest-mock";
2020
import {
2121
MatrixEvent,
2222
RoomStateEvent,
23-
IEvent,
2423
Room,
2524
IMinimalEvent,
2625
EventType,
@@ -266,9 +265,8 @@ describe("<PinnedMessagesCard />", () => {
266265
// Redacted messages are unpinnable
267266
const pin = mkEvent({
268267
event: true,
269-
type: EventType.RoomMessage,
268+
type: EventType.RoomCreate,
270269
content: {},
271-
unsigned: { redacted_because: {} as unknown as IEvent },
272270
room: "!room:example.org",
273271
user: "@alice:example.org",
274272
});
@@ -280,9 +278,8 @@ describe("<PinnedMessagesCard />", () => {
280278
// Redacted messages are unpinnable
281279
const pin = mkEvent({
282280
event: true,
283-
type: EventType.RoomMessage,
281+
type: EventType.RoomCreate,
284282
content: {},
285-
unsigned: { redacted_because: {} as unknown as IEvent },
286283
room: "!room:example.org",
287284
user: "@alice:example.org",
288285
});

test/utils/PinningUtils-test.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,27 @@ describe("PinningUtils", () => {
7575
).mockReturnValue(true);
7676
});
7777

78-
describe("isPinnable", () => {
78+
describe("isUnpinnable", () => {
7979
test.each(PinningUtils.PINNABLE_EVENT_TYPES)("should return true for pinnable event types", (eventType) => {
8080
const event = makePinEvent({ type: eventType });
81-
expect(PinningUtils.isPinnable(event)).toBe(true);
81+
expect(PinningUtils.isUnpinnable(event)).toBe(true);
8282
});
8383

8484
test("should return false for a non pinnable event type", () => {
8585
const event = makePinEvent({ type: EventType.RoomCreate });
86-
expect(PinningUtils.isPinnable(event)).toBe(false);
86+
expect(PinningUtils.isUnpinnable(event)).toBe(false);
87+
});
88+
89+
test("should return true for a redacted event", () => {
90+
const event = makePinEvent({ unsigned: { redacted_because: "because" as unknown as IEvent } });
91+
expect(PinningUtils.isUnpinnable(event)).toBe(true);
92+
});
93+
});
94+
95+
describe("isPinnable", () => {
96+
test.each(PinningUtils.PINNABLE_EVENT_TYPES)("should return true for pinnable event types", (eventType) => {
97+
const event = makePinEvent({ type: eventType });
98+
expect(PinningUtils.isPinnable(event)).toBe(true);
8799
});
88100

89101
test("should return false for a redacted event", () => {

0 commit comments

Comments
 (0)