mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
user_topics: Add the missing node tests.
This commit adds the missing node tests for the case
when the visibility policy is UNMUTED.
This should have been included in c526543.
This commit is contained in:
committed by
Tim Abbott
parent
32b201d5e0
commit
08c952a2a3
@@ -139,12 +139,56 @@ test("get_mutes", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("get_unmutes", () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
user_topics.get_user_topics_for_visibility_policy(
|
||||||
|
user_topics.all_visibility_policies.UNMUTED,
|
||||||
|
),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
user_topics.update_user_topics(
|
||||||
|
office.stream_id,
|
||||||
|
"gossip",
|
||||||
|
all_visibility_policies.UNMUTED,
|
||||||
|
1577836800,
|
||||||
|
);
|
||||||
|
user_topics.update_user_topics(
|
||||||
|
devel.stream_id,
|
||||||
|
"java",
|
||||||
|
all_visibility_policies.UNMUTED,
|
||||||
|
1577836700,
|
||||||
|
);
|
||||||
|
const all_unmuted_topics = user_topics
|
||||||
|
.get_user_topics_for_visibility_policy(user_topics.all_visibility_policies.UNMUTED)
|
||||||
|
.sort((a, b) => a.date_updated - b.date_updated);
|
||||||
|
|
||||||
|
assert.deepEqual(all_unmuted_topics, [
|
||||||
|
{
|
||||||
|
date_updated: 1577836700000,
|
||||||
|
date_updated_str: "Dec 31, 2019",
|
||||||
|
stream: devel.name,
|
||||||
|
stream_id: devel.stream_id,
|
||||||
|
topic: "java",
|
||||||
|
visibility_policy: all_visibility_policies.UNMUTED,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
date_updated: 1577836800000,
|
||||||
|
date_updated_str: "Jan 1, 2020",
|
||||||
|
stream: office.name,
|
||||||
|
stream_id: office.stream_id,
|
||||||
|
topic: "gossip",
|
||||||
|
visibility_policy: all_visibility_policies.UNMUTED,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
test("set_user_topics", () => {
|
test("set_user_topics", () => {
|
||||||
blueslip.expect("warn", "Unknown stream ID in set_user_topic: 999");
|
blueslip.expect("warn", "Unknown stream ID in set_user_topic: 999");
|
||||||
|
|
||||||
user_topics.set_user_topics([]);
|
user_topics.set_user_topics([]);
|
||||||
assert.ok(!user_topics.is_topic_muted(social.stream_id, "breakfast"));
|
assert.ok(!user_topics.is_topic_muted(social.stream_id, "breakfast"));
|
||||||
assert.ok(!user_topics.is_topic_muted(design.stream_id, "typography"));
|
assert.ok(!user_topics.is_topic_muted(design.stream_id, "typography"));
|
||||||
|
assert.ok(!user_topics.is_topic_unmuted(office.stream_id, "lunch"));
|
||||||
|
|
||||||
page_params.user_topics = [
|
page_params.user_topics = [
|
||||||
{
|
{
|
||||||
@@ -165,6 +209,12 @@ test("set_user_topics", () => {
|
|||||||
last_updated: "1577836800",
|
last_updated: "1577836800",
|
||||||
visibility_policy: all_visibility_policies.MUTED,
|
visibility_policy: all_visibility_policies.MUTED,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
stream_id: office.stream_id,
|
||||||
|
topic_name: "lunch",
|
||||||
|
last_updated: "1577836800",
|
||||||
|
visibility_policy: all_visibility_policies.UNMUTED,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
user_topics.initialize();
|
user_topics.initialize();
|
||||||
@@ -193,6 +243,22 @@ test("set_user_topics", () => {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
user_topics
|
||||||
|
.get_user_topics_for_visibility_policy(user_topics.all_visibility_policies.UNMUTED)
|
||||||
|
.sort(),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
date_updated: 1577836800000,
|
||||||
|
date_updated_str: "Jan 1, 2020",
|
||||||
|
stream: office.name,
|
||||||
|
stream_id: office.stream_id,
|
||||||
|
topic: "lunch",
|
||||||
|
visibility_policy: all_visibility_policies.UNMUTED,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
user_topics.set_user_topic({
|
user_topics.set_user_topic({
|
||||||
stream_id: design.stream_id,
|
stream_id: design.stream_id,
|
||||||
topic_name: "typography",
|
topic_name: "typography",
|
||||||
@@ -200,6 +266,14 @@ test("set_user_topics", () => {
|
|||||||
visibility_policy: all_visibility_policies.INHERIT,
|
visibility_policy: all_visibility_policies.INHERIT,
|
||||||
});
|
});
|
||||||
assert.ok(!user_topics.is_topic_muted(design.stream_id, "typography"));
|
assert.ok(!user_topics.is_topic_muted(design.stream_id, "typography"));
|
||||||
|
|
||||||
|
user_topics.set_user_topic({
|
||||||
|
stream_id: office.stream_id,
|
||||||
|
topic_name: "lunch",
|
||||||
|
last_updated: "1577836800",
|
||||||
|
visibility_policy: all_visibility_policies.INHERIT,
|
||||||
|
});
|
||||||
|
assert.ok(!user_topics.is_topic_unmuted(devel.stream_id, "lunch"));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("case_insensitivity", () => {
|
test("case_insensitivity", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user