mirror of https://github.com/zulip/zulip.git
node-tests: Remove mock of `topic_list` in `topic_list_data.test`.
With commit f0d1332ba2
, we no longer need to mock `topic_list.js`
in the `topic_list_data` node test. Instead, we can pass a string
directly to that function. The default is an empty string unless
there is a search input. Also, updates the default of the zoom to
be false instead of undefined in the tests.
This commit is contained in:
parent
9ed1c79f1b
commit
b9023db04e
|
@ -24,10 +24,6 @@ const narrow_state = mock_esm("../src/narrow_state", {
|
|||
topic() {},
|
||||
});
|
||||
|
||||
const topic_list = mock_esm("../src/topic_list", {
|
||||
get_topic_search_term() {},
|
||||
});
|
||||
|
||||
const stream_data = zrequire("stream_data");
|
||||
const stream_topic_history = zrequire("stream_topic_history");
|
||||
const topic_list_data = zrequire("topic_list_data");
|
||||
|
@ -40,9 +36,11 @@ const general = {
|
|||
|
||||
stream_data.add_sub(general);
|
||||
|
||||
function get_list_info(zoomed) {
|
||||
function get_list_info(zoom, search) {
|
||||
const stream_id = general.stream_id;
|
||||
return topic_list_data.get_list_info(stream_id, zoomed, topic_list.get_topic_search_term());
|
||||
const zoomed = zoom === undefined ? false : zoom;
|
||||
const search_term = search === undefined ? "" : search;
|
||||
return topic_list_data.get_list_info(stream_id, zoomed, search_term);
|
||||
}
|
||||
|
||||
function test(label, f) {
|
||||
|
@ -112,11 +110,10 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
|
|||
unread: 0,
|
||||
url: "#narrow/stream/556-general/topic/topic.208",
|
||||
});
|
||||
// If we zoom in, our results based on topic filter.
|
||||
// If topic search input is empty, we show all 10 topics.
|
||||
|
||||
// If we zoom in, our results are based on topic filter.
|
||||
// If topic search input is empty, we show all 10 topics.
|
||||
const zoomed = true;
|
||||
override(topic_list, "get_topic_search_term", () => "");
|
||||
list_info = get_list_info(zoomed);
|
||||
assert.equal(list_info.items.length, 10);
|
||||
assert.equal(list_info.more_topics_unreads, 0);
|
||||
|
@ -125,9 +122,11 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
|
|||
|
||||
add_topic_message("After Brooklyn", 1008);
|
||||
add_topic_message("Catering", 1009);
|
||||
// when topic search is open then we list topics based on search term.
|
||||
override(topic_list, "get_topic_search_term", () => "b,c");
|
||||
list_info = get_list_info(zoomed);
|
||||
|
||||
// When topic search input is not empty, we show topics
|
||||
// based on the search term.
|
||||
const search_term = "b,c";
|
||||
list_info = get_list_info(zoomed, search_term);
|
||||
assert.equal(list_info.items.length, 2);
|
||||
assert.equal(list_info.more_topics_unreads, 0);
|
||||
assert.equal(list_info.more_topics_have_unread_mention_messages, false);
|
||||
|
|
Loading…
Reference in New Issue