node tests: Clean up all_topics_in_cache test.

We use override() and clear the message data
explicitly.
This commit is contained in:
Steve Howell 2021-03-12 19:16:10 +00:00 committed by Steve Howell
parent 88357579fe
commit a0534b5b03
1 changed files with 8 additions and 2 deletions

View File

@ -813,7 +813,7 @@ test("get_invite_stream_data", () => {
assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);
});
test("all_topics_in_cache", () => {
test("all_topics_in_cache", (override) => {
// Add a new stream with first_message_id set.
const general = {
name: "general",
@ -829,9 +829,15 @@ test("all_topics_in_cache", () => {
assert.equal(stream_data.all_topics_in_cache(sub), false);
message_list.all.data.clear();
message_list.all.data.add_messages(messages);
let has_found_newest = false;
override(message_list.all.data.fetch_status, "has_found_newest", () => has_found_newest);
assert.equal(stream_data.all_topics_in_cache(sub), false);
message_list.all.data.fetch_status.has_found_newest = () => true;
has_found_newest = true;
assert.equal(stream_data.all_topics_in_cache(sub), true);
sub.first_message_id = 0;