node tests: Test direct mentions.

This never got tested despite 100% line coverage, due to
a boolean expression.
This commit is contained in:
Steve Howell
2021-08-04 16:46:15 +00:00
committed by Tim Abbott
parent 49901e9eca
commit 1901e980c9

View File

@@ -510,31 +510,49 @@ test("mentions", () => {
unread: true,
};
const muted_direct_mention_message = {
id: 17,
type: "stream",
stream_id: muted_stream_id,
topic: "lunch",
mentioned: true,
mentioned_me_directly: true,
unread: true,
};
unread.process_loaded_messages([
already_read_message,
mention_me_message,
mention_all_message,
muted_mention_all_message,
muted_direct_mention_message,
]);
counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 2);
assert.equal(counts.mentioned_message_count, 3);
assert.deepEqual(unread.get_msg_ids_for_mentions(), [
mention_me_message.id,
mention_all_message.id,
muted_direct_mention_message.id,
]);
assert.deepEqual(unread.get_all_msg_ids(), [
mention_me_message.id,
mention_all_message.id,
muted_mention_all_message.id,
]);
test_notifiable_count(counts.home_unread_messages, 2);
test_notifiable_count(counts.home_unread_messages, 3);
unread.mark_as_read(mention_me_message.id);
unread.mark_as_read(mention_all_message.id);
unread.mark_as_read(muted_direct_mention_message.id);
counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 0);
test_notifiable_count(counts.home_unread_messages, 0);
// redundantly read a message to make sure nothing explodes
unread.mark_as_read(muted_direct_mention_message.id);
counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 0);
});
test("mention updates", () => {