message_flags: Verify early return from send_read on_sucess.

This commit is contained in:
YashRE42 2021-03-19 17:11:04 +00:00 committed by Tim Abbott
parent ba8a6affd4
commit bb51fe075a
1 changed files with 28 additions and 0 deletions

View File

@ -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;