Refactor tests
So that there's one top level `describe('TextForEvent')`, followed by a nested `describe('textForPinnedEvent')`, containting all the `it()`s. Signed-off-by: Paulo Pinto <paulo.pinto@automattic.com>
This commit is contained in:
parent
94d3dd6bbc
commit
45fd3d83b0
2 changed files with 77 additions and 101 deletions
|
@ -23,88 +23,64 @@ function mockPinnedEvent(
|
|||
});
|
||||
}
|
||||
|
||||
describe("TextForPinnedEvent - newly pinned message(s)", () => {
|
||||
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
|
||||
describe('TextForEvent', () => {
|
||||
describe("TextForPinnedEvent", () => {
|
||||
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
|
||||
|
||||
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 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.");
|
||||
});
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows generic text when multiple messages were pinned", () => {
|
||||
const event = mockPinnedEvent(['message-1', 'message-2', 'message-3'], ['message-1']);
|
||||
expect(textForEvent(event)).toBe("@foo:example.com changed the pinned messages for the room.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("TextForPinnedEvent - newly pinned message(s) (JSX)", () => {
|
||||
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
|
||||
|
||||
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-1', 'message-2', 'message-3'], ['message-1']);
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe("TextForPinnedEvent - newly unpinned message(s)", () => {
|
||||
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
|
||||
|
||||
it("mentions message when a single message was unpinned, with a single message previously pinned", () => {
|
||||
const event = mockPinnedEvent([], ['message-1']);
|
||||
expect(textForEvent(event)).toBe(
|
||||
"@foo:example.com unpinned a message from this room. See all pinned messages.",
|
||||
);
|
||||
});
|
||||
|
||||
it("mentions message when a single message was unpinned, with multiple previously pinned messages", () => {
|
||||
const event = mockPinnedEvent(['message-2'], ['message-1', 'message-2']);
|
||||
expect(textForEvent(event)).toBe(
|
||||
"@foo:example.com unpinned a message from this room. See all pinned messages.",
|
||||
);
|
||||
});
|
||||
|
||||
it("shows generic text when multiple messages were unpinned", () => {
|
||||
const event = mockPinnedEvent(['message-3'], ['message-1', 'message-2', 'message-3']);
|
||||
expect(textForEvent(event)).toBe("@foo:example.com changed the pinned messages for the room.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("TextForPinnedEvent - newly unpinned message(s) (JSX)", () => {
|
||||
SettingsStore.setValue("feature_pinning", null, SettingLevel.DEVICE, true);
|
||||
|
||||
it("mentions message when a single message was unpinned, with a single message previously pinned", () => {
|
||||
const event = mockPinnedEvent([], ['message-1']);
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("mentions message when a single message was unpinned, with multiple previously pinned messages", () => {
|
||||
const event = mockPinnedEvent(['message-2'], ['message-1', 'message-2']);
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows generic text when multiple messages were unpinned", () => {
|
||||
const event = mockPinnedEvent(['message-3'], ['message-1', 'message-2', 'message-3']);
|
||||
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']);
|
||||
expect(textForEvent(event)).toBe(
|
||||
"@foo:example.com pinned a message to this room. See all pinned messages.",
|
||||
);
|
||||
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows generic text when multiple messages were pinned", () => {
|
||||
const event = mockPinnedEvent(['message-1', 'message-2', 'message-3'], ['message-1']);
|
||||
expect(textForEvent(event)).toBe("@foo:example.com changed the pinned messages for the room.");
|
||||
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("mentions message when a single message was unpinned, with a single message previously pinned", () => {
|
||||
const event = mockPinnedEvent([], ['message-1']);
|
||||
expect(textForEvent(event)).toBe(
|
||||
"@foo:example.com unpinned a message from this room. See all pinned messages.",
|
||||
);
|
||||
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("mentions message when a single message was unpinned, with multiple previously pinned messages", () => {
|
||||
const event = mockPinnedEvent(['message-2'], ['message-1', 'message-2']);
|
||||
expect(textForEvent(event)).toBe(
|
||||
"@foo:example.com unpinned a message from this room. See all pinned messages.",
|
||||
);
|
||||
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows generic text when multiple messages were unpinned", () => {
|
||||
const event = mockPinnedEvent(['message-3'], ['message-1', 'message-2', 'message-3']);
|
||||
expect(textForEvent(event)).toBe("@foo:example.com changed the pinned messages for the room.");
|
||||
|
||||
const component = renderer.create(textForEvent(event, true));
|
||||
expect(component.toJSON()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`TextForPinnedEvent - newly pinned message(s) (JSX) mentions message when a single message was pinned, with multiple previously pinned messages 1`] = `
|
||||
exports[`TextForEvent TextForPinnedEvent mentions message when a single message was pinned, with multiple previously pinned messages 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com pinned
|
||||
|
@ -20,7 +20,7 @@ exports[`TextForPinnedEvent - newly pinned message(s) (JSX) mentions message whe
|
|||
</span>
|
||||
`;
|
||||
|
||||
exports[`TextForPinnedEvent - newly pinned message(s) (JSX) mentions message when a single message was pinned, with no previously pinned messages 1`] = `
|
||||
exports[`TextForEvent TextForPinnedEvent mentions message when a single message was pinned, with no previously pinned messages 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com pinned
|
||||
|
@ -40,23 +40,7 @@ exports[`TextForPinnedEvent - newly pinned message(s) (JSX) mentions message whe
|
|||
</span>
|
||||
`;
|
||||
|
||||
exports[`TextForPinnedEvent - newly pinned message(s) (JSX) shows generic text when multiple messages were pinned 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com changed the
|
||||
<a
|
||||
onClick={[Function]}
|
||||
>
|
||||
|
||||
pinned messages
|
||||
|
||||
</a>
|
||||
for the room.
|
||||
</span>
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`TextForPinnedEvent - newly unpinned message(s) (JSX) mentions message when a single message was unpinned, with a single message previously pinned 1`] = `
|
||||
exports[`TextForEvent TextForPinnedEvent mentions message when a single message was unpinned, with a single message previously pinned 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com unpinned
|
||||
|
@ -76,7 +60,7 @@ exports[`TextForPinnedEvent - newly unpinned message(s) (JSX) mentions message w
|
|||
</span>
|
||||
`;
|
||||
|
||||
exports[`TextForPinnedEvent - newly unpinned message(s) (JSX) mentions message when a single message was unpinned, with multiple previously pinned messages 1`] = `
|
||||
exports[`TextForEvent TextForPinnedEvent mentions message when a single message was unpinned, with multiple previously pinned messages 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com unpinned
|
||||
|
@ -96,7 +80,23 @@ exports[`TextForPinnedEvent - newly unpinned message(s) (JSX) mentions message w
|
|||
</span>
|
||||
`;
|
||||
|
||||
exports[`TextForPinnedEvent - newly unpinned message(s) (JSX) shows generic text when multiple messages were unpinned 1`] = `
|
||||
exports[`TextForEvent TextForPinnedEvent shows generic text when multiple messages were pinned 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com changed the
|
||||
<a
|
||||
onClick={[Function]}
|
||||
>
|
||||
|
||||
pinned messages
|
||||
|
||||
</a>
|
||||
for the room.
|
||||
</span>
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`TextForEvent TextForPinnedEvent shows generic text when multiple messages were unpinned 1`] = `
|
||||
<span>
|
||||
<span>
|
||||
@foo:example.com changed the
|
||||
|
|
Loading…
Reference in a new issue