Skip to content

Commit 76674e6

Browse files
committed
ActionSheet: Add tests for mark as read option.
1 parent 64e8be4 commit 76674e6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/message/__tests__/messageActionSheet-test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,34 @@ describe('constructActionButtons', () => {
5858
});
5959

6060
describe('constructTopicActionButtons', () => {
61+
test('show mark as read if topic is unread', () => {
62+
const stream = eg.makeStream({ name: 'test stream', streamId: 123 });
63+
const subscriptions = [{ ...eg.subscription, ...stream }];
64+
const unreadStreams = eg.makeUnreadStreamsState([
65+
{ streamId: 123, topics: [{ topicName: 'test topic', messageIds: [1, 2] }] },
66+
]);
67+
const buttons = constructTopicActionButtons({
68+
backgroundData: { ...baseBackgroundData, subscriptions, unreadStreams },
69+
stream: 'test stream',
70+
topic: 'test topic',
71+
});
72+
expect(buttonTitles(buttons)).toContain('Mark topic as read');
73+
});
74+
75+
test('do not show mark as read if topic is read', () => {
76+
const stream = eg.makeStream({ name: 'test stream', streamId: 123 });
77+
const subscriptions = [{ ...eg.subscription, ...stream }];
78+
const unreadStreams = eg.makeUnreadStreamsState([
79+
{ streamId: 123, topics: [{ topicName: 'unread topic', messageIds: [1, 2] }] },
80+
]);
81+
const buttons = constructTopicActionButtons({
82+
backgroundData: { ...baseBackgroundData, subscriptions, unreadStreams },
83+
stream: 'test stream',
84+
topic: 'read topic',
85+
});
86+
expect(buttonTitles(buttons)).not.toContain('Mark topic as read');
87+
});
88+
6189
test('show Unmute topic option if topic is muted', () => {
6290
const mute = deepFreeze([['electron issues', 'issue #556']]);
6391
const buttons = constructTopicActionButtons({

0 commit comments

Comments
 (0)