message_flags: Add coverage for get_starred_message_ids_in_topic call.

This commit is contained in:
YashRE42 2021-03-24 04:44:40 +00:00 committed by Tim Abbott
parent f461139d26
commit feabaebcad
1 changed files with 17 additions and 1 deletions

View File

@ -10,7 +10,7 @@ const ui = mock_esm("../../static/js/ui");
mock_esm("../../static/js/starred_messages", { mock_esm("../../static/js/starred_messages", {
add: () => {}, add: () => {},
get_starred_message_ids_in_topic: () => [2, 4, 5],
remove: () => {}, remove: () => {},
}); });
@ -88,6 +88,22 @@ run_test("starring local echo", () => {
}); });
}); });
run_test("unstar_all_in_topic", (override) => {
// Way to capture posted info in every request
let posted_data;
override(channel, "post", (opts) => {
assert.equal(opts.url, "/json/messages/flags");
posted_data = opts.data;
});
// we've set get_starred_message_ids_in_topic to return [2, 4, 5]
const expected_data = {messages: "[2,4,5]", flag: "starred", op: "remove"};
message_flags.unstar_all_messages_in_topic(20, "topic");
assert.deepEqual(posted_data, expected_data);
});
run_test("read", (override) => { run_test("read", (override) => {
// Way to capture posted info in every request // Way to capture posted info in every request
let channel_post_opts; let channel_post_opts;