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

Commit

Permalink
Add tests for redaction
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Aug 27, 2024
1 parent 54f9723 commit 6ce4cc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 2 additions & 5 deletions test/components/views/right_panel/PinnedMessagesCard-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { mocked, MockedObject } from "jest-mock";
import {
MatrixEvent,
RoomStateEvent,
IEvent,
Room,
IMinimalEvent,
EventType,
Expand Down Expand Up @@ -266,9 +265,8 @@ describe("<PinnedMessagesCard />", () => {
// Redacted messages are unpinnable
const pin = mkEvent({
event: true,
type: EventType.RoomMessage,
type: EventType.RoomCreate,
content: {},
unsigned: { redacted_because: {} as unknown as IEvent },
room: "!room:example.org",
user: "@alice:example.org",
});
Expand All @@ -280,9 +278,8 @@ describe("<PinnedMessagesCard />", () => {
// Redacted messages are unpinnable
const pin = mkEvent({
event: true,
type: EventType.RoomMessage,
type: EventType.RoomCreate,
content: {},
unsigned: { redacted_because: {} as unknown as IEvent },
room: "!room:example.org",
user: "@alice:example.org",
});
Expand Down
18 changes: 15 additions & 3 deletions test/utils/PinningUtils-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,27 @@ describe("PinningUtils", () => {
).mockReturnValue(true);
});

describe("isPinnable", () => {
describe("isUnpinnable", () => {
test.each(PinningUtils.PINNABLE_EVENT_TYPES)("should return true for pinnable event types", (eventType) => {
const event = makePinEvent({ type: eventType });
expect(PinningUtils.isPinnable(event)).toBe(true);
expect(PinningUtils.isUnpinnable(event)).toBe(true);
});

test("should return false for a non pinnable event type", () => {
const event = makePinEvent({ type: EventType.RoomCreate });
expect(PinningUtils.isPinnable(event)).toBe(false);
expect(PinningUtils.isUnpinnable(event)).toBe(false);
});

test("should return true for a redacted event", () => {
const event = makePinEvent({ unsigned: { redacted_because: "because" as unknown as IEvent } });
expect(PinningUtils.isUnpinnable(event)).toBe(true);
});
});

describe("isPinnable", () => {
test.each(PinningUtils.PINNABLE_EVENT_TYPES)("should return true for pinnable event types", (eventType) => {
const event = makePinEvent({ type: eventType });
expect(PinningUtils.isPinnable(event)).toBe(true);
});

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

0 comments on commit 6ce4cc8

Please sign in to comment.