mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
js: Convert static/js/unread.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
9997e13032
commit
727208b84c
@@ -90,7 +90,6 @@ rewiremock.enable();
|
||||
|
||||
const huddle_data = zrequire("huddle_data");
|
||||
const compose_fade = zrequire("compose_fade");
|
||||
zrequire("unread");
|
||||
const narrow = zrequire("narrow");
|
||||
const presence = zrequire("presence");
|
||||
const people = zrequire("people");
|
||||
|
||||
@@ -111,7 +111,6 @@ rewiremock.enable();
|
||||
|
||||
// For data-oriented modules, just use them, don't stub them.
|
||||
const alert_words = zrequire("alert_words");
|
||||
zrequire("unread");
|
||||
const stream_topic_history = zrequire("stream_topic_history");
|
||||
const stream_list = zrequire("stream_list");
|
||||
const message_store = zrequire("message_store");
|
||||
|
||||
@@ -14,7 +14,6 @@ const page_params = set_global("page_params", {});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
zrequire("unread");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const people = zrequire("people");
|
||||
const {Filter} = zrequire("Filter", "js/filter");
|
||||
|
||||
@@ -14,7 +14,6 @@ rewiremock("../../static/js/starred_messages").with({
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
zrequire("unread");
|
||||
const message_flags = zrequire("message_flags");
|
||||
|
||||
const ui = set_global("ui", {});
|
||||
|
||||
@@ -13,7 +13,6 @@ set_global("setTimeout", (f, delay) => {
|
||||
});
|
||||
|
||||
const muting = zrequire("muting");
|
||||
zrequire("unread");
|
||||
const {MessageListData} = zrequire("MessageListData", "js/message_list_data");
|
||||
|
||||
function make_msg(msg_id) {
|
||||
|
||||
@@ -16,7 +16,7 @@ const page_params = set_global("page_params", {
|
||||
twenty_four_hour_time: false,
|
||||
});
|
||||
set_global("home_msg_list", "stub");
|
||||
set_global("unread", {message_unread() {}});
|
||||
rewiremock("../../static/js/unread").with({message_unread() {}});
|
||||
// timerender calls setInterval when imported
|
||||
rewiremock("../../static/js/timerender").with({
|
||||
render_date(time1, time2) {
|
||||
|
||||
@@ -67,7 +67,6 @@ rewiremock.enable();
|
||||
const util = zrequire("util");
|
||||
const narrow_state = zrequire("narrow_state");
|
||||
const stream_data = zrequire("stream_data");
|
||||
zrequire("unread");
|
||||
const narrow = zrequire("narrow");
|
||||
|
||||
const denmark = {
|
||||
|
||||
@@ -16,7 +16,8 @@ set_global("ui", {
|
||||
rewiremock("../../static/js/stream_popover").with({
|
||||
hide_topic_popover() {},
|
||||
});
|
||||
const unread = set_global("unread", {});
|
||||
const unread = {__esModule: true};
|
||||
rewiremock("../../static/js/unread").with(unread);
|
||||
const unread_ui = {__esModule: true};
|
||||
rewiremock("../../static/js/unread_ui").with(unread_ui);
|
||||
const vdom = {
|
||||
|
||||
@@ -33,7 +33,7 @@ rewiremock("../../static/js/timerender").with({
|
||||
time: "time",
|
||||
}),
|
||||
});
|
||||
set_global("unread", {
|
||||
rewiremock("../../static/js/unread").with({
|
||||
unread_topic_counter: {
|
||||
get: (stream_id, topic) => {
|
||||
if (stream_id === 1 && topic === "topic-1") {
|
||||
|
||||
@@ -29,7 +29,6 @@ const narrow_state = zrequire("narrow_state");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const stream_topic_history = zrequire("stream_topic_history");
|
||||
const people = zrequire("people");
|
||||
zrequire("unread");
|
||||
const search = zrequire("search_suggestion");
|
||||
|
||||
search.__Rewire__("max_num_of_search_results", 15);
|
||||
|
||||
@@ -27,7 +27,6 @@ const narrow_state = zrequire("narrow_state");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const stream_topic_history = zrequire("stream_topic_history");
|
||||
const people = zrequire("people");
|
||||
zrequire("unread");
|
||||
const search = zrequire("search_suggestion");
|
||||
|
||||
search.__Rewire__("max_num_of_search_results", 15);
|
||||
|
||||
@@ -100,8 +100,9 @@ run_test("topics", () => {
|
||||
|
||||
stream_data.__Rewire__("is_stream_muted_by_name", (stream_name) => stream_name === "muted");
|
||||
|
||||
unread.topic_has_any_unread = (stream_id) =>
|
||||
[devel_stream_id, muted_stream_id].includes(stream_id);
|
||||
unread.__Rewire__("topic_has_any_unread", (stream_id) =>
|
||||
[devel_stream_id, muted_stream_id].includes(stream_id),
|
||||
);
|
||||
|
||||
muting.__Rewire__("is_topic_muted", (stream_name, topic) => topic === "muted");
|
||||
|
||||
@@ -121,7 +122,7 @@ run_test("topics", () => {
|
||||
run_test("get_next_unread_pm_string", () => {
|
||||
pm_conversations.recent.get_strings = () => ["1", "read", "2,3", "4", "unk"];
|
||||
|
||||
unread.num_unread_for_person = (user_ids_string) => {
|
||||
unread.__Rewire__("num_unread_for_person", (user_ids_string) => {
|
||||
if (user_ids_string === "unk") {
|
||||
return undefined;
|
||||
}
|
||||
@@ -131,7 +132,7 @@ run_test("get_next_unread_pm_string", () => {
|
||||
}
|
||||
|
||||
return 5; // random non-zero value
|
||||
};
|
||||
});
|
||||
|
||||
assert.equal(tg.get_next_unread_pm_string(), "1");
|
||||
assert.equal(tg.get_next_unread_pm_string("4"), "1");
|
||||
@@ -141,7 +142,7 @@ run_test("get_next_unread_pm_string", () => {
|
||||
assert.equal(tg.get_next_unread_pm_string("read"), "2,3");
|
||||
assert.equal(tg.get_next_unread_pm_string("2,3"), "4");
|
||||
|
||||
unread.num_unread_for_person = () => 0;
|
||||
unread.__Rewire__("num_unread_for_person", () => 0);
|
||||
|
||||
assert.equal(tg.get_next_unread_pm_string("2,3"), undefined);
|
||||
});
|
||||
|
||||
@@ -111,7 +111,6 @@ rewiremock.enable();
|
||||
|
||||
const util = zrequire("util");
|
||||
|
||||
zrequire("unread");
|
||||
const upload = zrequire("upload");
|
||||
const compose = zrequire("compose");
|
||||
zrequire("composebox_typeahead");
|
||||
|
||||
Reference in New Issue
Block a user