Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_flags: Verify early return from send_read on_sucess.

YashRE42bb51fe075a81
diff --git a/frontend_tests/node_tests/message_flags.js b/frontend_tests/node_tests/message_flags.js
index 4d792b92e22..df7b075f5d7 100644
--- a/frontend_tests/node_tests/message_flags.js
+++ b/frontend_tests/node_tests/message_flags.js
@@ -167,6 +167,34 @@ run_test("read", (override) => {
});
});
+run_test("read_empty_data", (override) => {
+ // Way to capture posted info in every request
+ let channel_post_opts;
+ override(channel, "post", (opts) => {
+ channel_post_opts = opts;
+ });
+
+ // For testing purpose limit the batch size value to 5 instead of 1000
+ function send_read(messages) {
+ with_field(message_flags, "_unread_batch_size", 5, () => {
+ message_flags.send_read(messages);
+ });
+ }
+
+ // send read to obtain success callback
+ send_read({locally_echoed: false, id: 1});
+
+ // verify early return on empty data
+ const success_callback = channel_post_opts.success;
+ channel_post_opts = {};
+ let empty_data;
+ success_callback(empty_data);
+ assert.deepEqual(channel_post_opts, {});
+ empty_data = {messages: undefined};
+ success_callback(empty_data);
+ assert.deepEqual(channel_post_opts, {});
+});
+
run_test("collapse_and_uncollapse", (override) => {
// Way to capture posted info in every request
let channel_post_opts;