When a single message is pinned, link to it

Signed-off-by: Paulo Pinto <paulo.pinto@automattic.com>
This commit is contained in:
Paulo Pinto 2021-07-27 15:37:05 +01:00
parent 40ead34c08
commit 8fe7df9171
4 changed files with 114 additions and 7 deletions

View file

@ -23,20 +23,42 @@ function mockPinnedEvent(
});
}
describe("TextForPinnedEvent", () => {
describe("TextForPinnedEvent - newly pinned message(s)", () => {
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
it("should mention sender", () => {
const event = mockPinnedEvent();
it("mentions message when a single message was pinned, with no previously pinned messages", () => {
const event = mockPinnedEvent(['message-1']);
expect(textForEvent(event)).toBe("@foo:example.com pinned a message to this room. See all pinned messages.");
});
it("mentions message when a single message was pinned, with multiple previously pinned messages", () => {
const event = mockPinnedEvent(['message-3'], ['message-1', 'message-2']);
expect(textForEvent(event)).toBe("@foo:example.com pinned a message to this room. See all pinned messages.");
});
it("shows generic text when multiple messages were pinned", () => {
const event = mockPinnedEvent(['message-2', 'message-3'], ['message-1']);
expect(textForEvent(event)).toBe("@foo:example.com changed the pinned messages for the room.");
});
});
describe("TextForPinnedEvent (JSX)", () => {
describe("TextForPinnedEvent - newly pinned message(s) (JSX)", () => {
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
it("should mention sender", () => {
const event = mockPinnedEvent();
it("mentions message when a single message was pinned, with no previously pinned messages", () => {
const event = mockPinnedEvent(['message-1']);
const component = renderer.create(textForEvent(event, true));
expect(component.toJSON()).toMatchSnapshot();
});
it("mentions message when a single message was pinned, with multiple previously pinned messages", () => {
const event = mockPinnedEvent(['message-3'], ['message-1', 'message-2']);
const component = renderer.create(textForEvent(event, true));
expect(component.toJSON()).toMatchSnapshot();
});
it("shows generic text when multiple messages were pinned", () => {
const event = mockPinnedEvent(['message-2', 'message-3'], ['message-1']);
const component = renderer.create(textForEvent(event, true));
expect(component.toJSON()).toMatchSnapshot();
});