mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	node tests: Introduce mock_module helper.
This commit is contained in:
		
				
					committed by
					
						
						Steve Howell
					
				
			
			
				
	
			
			
			
						parent
						
							167fda142c
						
					
				
				
					commit
					f54f7cfc33
				
			@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -56,20 +56,20 @@ const _resize = {
 | 
			
		||||
    resize_page_components: () => {},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/padded_widget").with({
 | 
			
		||||
mock_module("padded_widget", {
 | 
			
		||||
    update_padding: () => {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/channel").with(channel);
 | 
			
		||||
rewiremock("../../static/js/compose_state").with(compose_state);
 | 
			
		||||
rewiremock("../../static/js/keydown_util").with(_keydown_util);
 | 
			
		||||
rewiremock("../../static/js/pm_list").with(_pm_list);
 | 
			
		||||
rewiremock("../../static/js/popovers").with(_popovers);
 | 
			
		||||
rewiremock("../../static/js/resize").with(_resize);
 | 
			
		||||
rewiremock("../../static/js/scroll_util").with(_scroll_util);
 | 
			
		||||
rewiremock("../../static/js/server_events").with({
 | 
			
		||||
mock_module("channel", channel);
 | 
			
		||||
mock_module("compose_state", compose_state);
 | 
			
		||||
mock_module("keydown_util", _keydown_util);
 | 
			
		||||
mock_module("pm_list", _pm_list);
 | 
			
		||||
mock_module("popovers", _popovers);
 | 
			
		||||
mock_module("resize", _resize);
 | 
			
		||||
mock_module("scroll_util", _scroll_util);
 | 
			
		||||
mock_module("server_events", {
 | 
			
		||||
    check_for_unsuspend() {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/stream_popover").with(_stream_popover);
 | 
			
		||||
mock_module("stream_popover", _stream_popover);
 | 
			
		||||
set_global("document", _document);
 | 
			
		||||
 | 
			
		||||
const huddle_data = zrequire("huddle_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,13 +3,13 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const channel = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/channel").with(channel);
 | 
			
		||||
mock_module("channel", channel);
 | 
			
		||||
const alert_words = zrequire("alert_words");
 | 
			
		||||
 | 
			
		||||
const alert_words_ui = zrequire("alert_words_ui");
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ const fs = require("fs");
 | 
			
		||||
 | 
			
		||||
const {JSDOM} = require("jsdom");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -19,7 +19,7 @@ const helpers = {
 | 
			
		||||
const StripeCheckout = set_global("StripeCheckout", {
 | 
			
		||||
    configure: () => {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/billing/helpers").with(helpers);
 | 
			
		||||
mock_module("billing/helpers", helpers);
 | 
			
		||||
 | 
			
		||||
run_test("initialize", (override) => {
 | 
			
		||||
    let token_func;
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ const fs = require("fs");
 | 
			
		||||
const jQueryFactory = require("jquery");
 | 
			
		||||
const {JSDOM} = require("jsdom");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -16,7 +16,7 @@ const jquery = jQueryFactory(dom.window);
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const history = set_global("history", {});
 | 
			
		||||
const loading = rewiremock("../../static/js/loading").with({});
 | 
			
		||||
const loading = mock_module("loading");
 | 
			
		||||
set_global("document", {
 | 
			
		||||
    title: "Zulip",
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -2,14 +2,14 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const _settings_bots = {
 | 
			
		||||
    render_bots: () => {},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/settings_bots").with(_settings_bots);
 | 
			
		||||
mock_module("settings_bots", _settings_bots);
 | 
			
		||||
const bot_data = zrequire("bot_data");
 | 
			
		||||
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,14 +4,14 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const timerender = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/timerender").with(timerender);
 | 
			
		||||
mock_module("timerender", timerender);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const presence = zrequire("presence");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,15 +4,15 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/padded_widget").with({
 | 
			
		||||
mock_module("padded_widget", {
 | 
			
		||||
    update_padding: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_viewport").with({
 | 
			
		||||
mock_module("message_viewport", {
 | 
			
		||||
    height: () => 550,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,12 +4,12 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const reload = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/reload").with(reload);
 | 
			
		||||
mock_module("reload", reload);
 | 
			
		||||
set_global("setTimeout", (f, delay) => {
 | 
			
		||||
    assert.equal(delay, 0);
 | 
			
		||||
    f();
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ const {JSDOM} = require("jsdom");
 | 
			
		||||
const MockDate = require("mockdate");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -17,7 +17,7 @@ set_global("DOMParser", new JSDOM().window.DOMParser);
 | 
			
		||||
let compose_actions_start_checked;
 | 
			
		||||
let compose_actions_expected_opts;
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose_actions").with({
 | 
			
		||||
mock_module("compose_actions", {
 | 
			
		||||
    update_placeholder_text: noop,
 | 
			
		||||
 | 
			
		||||
    start(msg_type, opts) {
 | 
			
		||||
@@ -27,7 +27,7 @@ rewiremock("../../static/js/compose_actions").with({
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const server_events = rewiremock("../../static/js/server_events").with({});
 | 
			
		||||
const server_events = mock_module("server_events");
 | 
			
		||||
const _navigator = {
 | 
			
		||||
    platform: "",
 | 
			
		||||
};
 | 
			
		||||
@@ -56,27 +56,27 @@ const reminder = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
set_global("document", _document);
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const loading = rewiremock("../../static/js/loading").with({});
 | 
			
		||||
const local_message = rewiremock("../../static/js/local_message").with({});
 | 
			
		||||
const markdown = rewiremock("../../static/js/markdown").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const loading = mock_module("loading");
 | 
			
		||||
const local_message = mock_module("local_message");
 | 
			
		||||
const markdown = mock_module("markdown");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const resize = rewiremock("../../static/js/resize").with({});
 | 
			
		||||
const stream_edit = rewiremock("../../static/js/stream_edit").with({});
 | 
			
		||||
const subs = rewiremock("../../static/js/subs").with({});
 | 
			
		||||
const transmit = rewiremock("../../static/js/transmit").with({});
 | 
			
		||||
rewiremock("../../static/js/drafts").with(_drafts);
 | 
			
		||||
rewiremock("../../static/js/notifications").with(_notifications);
 | 
			
		||||
rewiremock("../../static/js/reminder").with(reminder);
 | 
			
		||||
rewiremock("../../static/js/rendered_markdown").with({
 | 
			
		||||
const resize = mock_module("resize");
 | 
			
		||||
const stream_edit = mock_module("stream_edit");
 | 
			
		||||
const subs = mock_module("subs");
 | 
			
		||||
const transmit = mock_module("transmit");
 | 
			
		||||
mock_module("drafts", _drafts);
 | 
			
		||||
mock_module("notifications", _notifications);
 | 
			
		||||
mock_module("reminder", reminder);
 | 
			
		||||
mock_module("rendered_markdown", {
 | 
			
		||||
    update_elements: () => {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/sent_messages").with(sent_messages);
 | 
			
		||||
mock_module("sent_messages", sent_messages);
 | 
			
		||||
set_global("navigator", _navigator);
 | 
			
		||||
 | 
			
		||||
const ui_util = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui_util").with(ui_util);
 | 
			
		||||
mock_module("ui_util", ui_util);
 | 
			
		||||
// Setting these up so that we can test that links to uploads within messages are
 | 
			
		||||
 | 
			
		||||
// automatically converted to server relative links.
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -17,14 +17,14 @@ set_global("document", {
 | 
			
		||||
 | 
			
		||||
const compose_pm_pill = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose_pm_pill").with(compose_pm_pill);
 | 
			
		||||
mock_module("compose_pm_pill", compose_pm_pill);
 | 
			
		||||
const hash_util = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/hash_util").with(hash_util);
 | 
			
		||||
rewiremock("../../static/js/notifications").with({
 | 
			
		||||
mock_module("hash_util", hash_util);
 | 
			
		||||
mock_module("notifications", {
 | 
			
		||||
    clear_compose_notifications: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/reload_state").with({
 | 
			
		||||
mock_module("reload_state", {
 | 
			
		||||
    is_in_progress: () => false,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -32,8 +32,8 @@ const compose_fade = {
 | 
			
		||||
    clear_compose: noop,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose_fade").with(compose_fade);
 | 
			
		||||
rewiremock("../../static/js/drafts").with({
 | 
			
		||||
mock_module("compose_fade", compose_fade);
 | 
			
		||||
mock_module("drafts", {
 | 
			
		||||
    update_draft: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -41,11 +41,11 @@ const narrow_state = {
 | 
			
		||||
    set_compose_defaults: noop,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/common").with({
 | 
			
		||||
mock_module("common", {
 | 
			
		||||
    status_classes: "status_classes",
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
 | 
			
		||||
rewiremock("../../static/js/unread_ops").with({
 | 
			
		||||
mock_module("narrow_state", narrow_state);
 | 
			
		||||
mock_module("unread_ops", {
 | 
			
		||||
    notify_server_message_read: noop,
 | 
			
		||||
});
 | 
			
		||||
set_global("current_msg_list", {
 | 
			
		||||
@@ -56,7 +56,7 @@ set_global("current_msg_list", {
 | 
			
		||||
 | 
			
		||||
const channel = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/channel").with(channel);
 | 
			
		||||
mock_module("channel", channel);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const compose_ui = zrequire("compose_ui");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const compose_actions = rewiremock("../../static/js/compose_actions").with({});
 | 
			
		||||
const compose_actions = mock_module("compose_actions");
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const compose_pm_pill = zrequire("compose_pm_pill");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,12 +2,12 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const compose_pm_pill = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose_pm_pill").with(compose_pm_pill);
 | 
			
		||||
mock_module("compose_pm_pill", compose_pm_pill);
 | 
			
		||||
const compose_state = zrequire("compose_state");
 | 
			
		||||
 | 
			
		||||
run_test("private_message_recipient", (override) => {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -11,10 +11,10 @@ const events = require("./lib/events");
 | 
			
		||||
const resize = {
 | 
			
		||||
    watch_manual_resize() {},
 | 
			
		||||
};
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const upload = rewiremock("../../static/js/upload").with({});
 | 
			
		||||
rewiremock("../../static/js/resize").with(resize);
 | 
			
		||||
const upload = mock_module("upload");
 | 
			
		||||
mock_module("resize", resize);
 | 
			
		||||
set_global("csrf_token", "fake-csrf-token");
 | 
			
		||||
set_global("document", {
 | 
			
		||||
    execCommand() {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -10,23 +10,23 @@ const noop = () => {};
 | 
			
		||||
 | 
			
		||||
const stream_topic_history = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_topic_history").with(stream_topic_history);
 | 
			
		||||
mock_module("stream_topic_history", stream_topic_history);
 | 
			
		||||
const message_store = {
 | 
			
		||||
    user_ids: () => [],
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
rewiremock("../../static/js/message_store").with(message_store);
 | 
			
		||||
mock_module("message_store", message_store);
 | 
			
		||||
 | 
			
		||||
const compose = {
 | 
			
		||||
    finish: noop,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose").with(compose);
 | 
			
		||||
mock_module("compose", compose);
 | 
			
		||||
let autosize_called;
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose_ui").with({
 | 
			
		||||
mock_module("compose_ui", {
 | 
			
		||||
    autosize_textarea() {
 | 
			
		||||
        autosize_called = true;
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
 | 
			
		||||
const jquery = require("jquery");
 | 
			
		||||
const {JSDOM} = require("jsdom");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
set_global("page_params", {
 | 
			
		||||
@@ -13,7 +13,7 @@ set_global("page_params", {
 | 
			
		||||
});
 | 
			
		||||
const compose_ui = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose_ui").with(compose_ui);
 | 
			
		||||
mock_module("compose_ui", compose_ui);
 | 
			
		||||
const {window} = new JSDOM("<!DOCTYPE html><p>Hello world</p>");
 | 
			
		||||
 | 
			
		||||
const {DOMParser, document} = window;
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
@@ -18,52 +18,52 @@ const typing_person1 = events.typing_person1;
 | 
			
		||||
 | 
			
		||||
set_global("setTimeout", (func) => func());
 | 
			
		||||
 | 
			
		||||
const activity = rewiremock("../../static/js/activity").with({});
 | 
			
		||||
const alert_words_ui = rewiremock("../../static/js/alert_words_ui").with({});
 | 
			
		||||
const attachments_ui = rewiremock("../../static/js/attachments_ui").with({});
 | 
			
		||||
const bot_data = rewiremock("../../static/js/bot_data").with({});
 | 
			
		||||
const composebox_typeahead = rewiremock("../../static/js/composebox_typeahead").with({});
 | 
			
		||||
const emoji_picker = rewiremock("../../static/js/emoji_picker").with({});
 | 
			
		||||
const hotspots = rewiremock("../../static/js/hotspots").with({});
 | 
			
		||||
const markdown = rewiremock("../../static/js/markdown").with({});
 | 
			
		||||
const message_edit = rewiremock("../../static/js/message_edit").with({});
 | 
			
		||||
const message_events = rewiremock("../../static/js/message_events").with({});
 | 
			
		||||
const message_list = rewiremock("../../static/js/message_list").with({});
 | 
			
		||||
const muting_ui = rewiremock("../../static/js/muting_ui").with({});
 | 
			
		||||
const night_mode = rewiremock("../../static/js/night_mode").with({});
 | 
			
		||||
const notifications = rewiremock("../../static/js/notifications").with({});
 | 
			
		||||
const reactions = rewiremock("../../static/js/reactions").with({});
 | 
			
		||||
const realm_icon = rewiremock("../../static/js/realm_icon").with({});
 | 
			
		||||
const realm_logo = rewiremock("../../static/js/realm_logo").with({});
 | 
			
		||||
const reload = rewiremock("../../static/js/reload").with({});
 | 
			
		||||
const scroll_bar = rewiremock("../../static/js/scroll_bar").with({});
 | 
			
		||||
const settings_account = rewiremock("../../static/js/settings_account").with({});
 | 
			
		||||
const settings_bots = rewiremock("../../static/js/settings_bots").with({});
 | 
			
		||||
const settings_display = rewiremock("../../static/js/settings_display").with({});
 | 
			
		||||
const settings_emoji = rewiremock("../../static/js/settings_emoji").with({});
 | 
			
		||||
const settings_exports = rewiremock("../../static/js/settings_exports").with({});
 | 
			
		||||
const settings_invites = rewiremock("../../static/js/settings_invites").with({});
 | 
			
		||||
const settings_linkifiers = rewiremock("../../static/js/settings_linkifiers").with({});
 | 
			
		||||
const settings_notifications = rewiremock("../../static/js/settings_notifications").with({});
 | 
			
		||||
const settings_org = rewiremock("../../static/js/settings_org").with({});
 | 
			
		||||
const settings_profile_fields = rewiremock("../../static/js/settings_profile_fields").with({});
 | 
			
		||||
const settings_streams = rewiremock("../../static/js/settings_streams").with({});
 | 
			
		||||
const settings_user_groups = rewiremock("../../static/js/settings_user_groups").with({});
 | 
			
		||||
const settings_users = rewiremock("../../static/js/settings_users").with({});
 | 
			
		||||
const stream_data = rewiremock("../../static/js/stream_data").with({});
 | 
			
		||||
const stream_events = rewiremock("../../static/js/stream_events").with({});
 | 
			
		||||
const submessage = rewiremock("../../static/js/submessage").with({});
 | 
			
		||||
const typing_events = rewiremock("../../static/js/typing_events").with({});
 | 
			
		||||
const ui = rewiremock("../../static/js/ui").with({});
 | 
			
		||||
const unread_ops = rewiremock("../../static/js/unread_ops").with({});
 | 
			
		||||
const user_events = rewiremock("../../static/js/user_events").with({});
 | 
			
		||||
rewiremock("../../static/js/compose").with({});
 | 
			
		||||
const activity = mock_module("activity");
 | 
			
		||||
const alert_words_ui = mock_module("alert_words_ui");
 | 
			
		||||
const attachments_ui = mock_module("attachments_ui");
 | 
			
		||||
const bot_data = mock_module("bot_data");
 | 
			
		||||
const composebox_typeahead = mock_module("composebox_typeahead");
 | 
			
		||||
const emoji_picker = mock_module("emoji_picker");
 | 
			
		||||
const hotspots = mock_module("hotspots");
 | 
			
		||||
const markdown = mock_module("markdown");
 | 
			
		||||
const message_edit = mock_module("message_edit");
 | 
			
		||||
const message_events = mock_module("message_events");
 | 
			
		||||
const message_list = mock_module("message_list");
 | 
			
		||||
const muting_ui = mock_module("muting_ui");
 | 
			
		||||
const night_mode = mock_module("night_mode");
 | 
			
		||||
const notifications = mock_module("notifications");
 | 
			
		||||
const reactions = mock_module("reactions");
 | 
			
		||||
const realm_icon = mock_module("realm_icon");
 | 
			
		||||
const realm_logo = mock_module("realm_logo");
 | 
			
		||||
const reload = mock_module("reload");
 | 
			
		||||
const scroll_bar = mock_module("scroll_bar");
 | 
			
		||||
const settings_account = mock_module("settings_account");
 | 
			
		||||
const settings_bots = mock_module("settings_bots");
 | 
			
		||||
const settings_display = mock_module("settings_display");
 | 
			
		||||
const settings_emoji = mock_module("settings_emoji");
 | 
			
		||||
const settings_exports = mock_module("settings_exports");
 | 
			
		||||
const settings_invites = mock_module("settings_invites");
 | 
			
		||||
const settings_linkifiers = mock_module("settings_linkifiers");
 | 
			
		||||
const settings_notifications = mock_module("settings_notifications");
 | 
			
		||||
const settings_org = mock_module("settings_org");
 | 
			
		||||
const settings_profile_fields = mock_module("settings_profile_fields");
 | 
			
		||||
const settings_streams = mock_module("settings_streams");
 | 
			
		||||
const settings_user_groups = mock_module("settings_user_groups");
 | 
			
		||||
const settings_users = mock_module("settings_users");
 | 
			
		||||
const stream_data = mock_module("stream_data");
 | 
			
		||||
const stream_events = mock_module("stream_events");
 | 
			
		||||
const submessage = mock_module("submessage");
 | 
			
		||||
const typing_events = mock_module("typing_events");
 | 
			
		||||
const ui = mock_module("ui");
 | 
			
		||||
const unread_ops = mock_module("unread_ops");
 | 
			
		||||
const user_events = mock_module("user_events");
 | 
			
		||||
mock_module("compose");
 | 
			
		||||
set_global("current_msg_list", {});
 | 
			
		||||
set_global("home_msg_list", {});
 | 
			
		||||
 | 
			
		||||
const user_groups = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/user_groups").with(user_groups);
 | 
			
		||||
mock_module("user_groups", user_groups);
 | 
			
		||||
// page_params is highly coupled to dispatching now
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
@@ -11,22 +11,22 @@ const events = require("./lib/events");
 | 
			
		||||
const event_fixtures = events.fixtures;
 | 
			
		||||
const test_user = events.test_user;
 | 
			
		||||
 | 
			
		||||
const compose_fade = rewiremock("../../static/js/compose_fade").with({});
 | 
			
		||||
const stream_events = rewiremock("../../static/js/stream_events").with({});
 | 
			
		||||
const compose_fade = mock_module("compose_fade");
 | 
			
		||||
const stream_events = mock_module("stream_events");
 | 
			
		||||
 | 
			
		||||
const subs = {};
 | 
			
		||||
 | 
			
		||||
const narrow_state = rewiremock("../../static/js/narrow_state").with({});
 | 
			
		||||
const overlays = rewiremock("../../static/js/overlays").with({});
 | 
			
		||||
const narrow_state = mock_module("narrow_state");
 | 
			
		||||
const overlays = mock_module("overlays");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const settings_org = rewiremock("../../static/js/settings_org").with({});
 | 
			
		||||
const settings_streams = rewiremock("../../static/js/settings_streams").with({});
 | 
			
		||||
rewiremock("../../static/js/subs").with(subs);
 | 
			
		||||
const settings_org = mock_module("settings_org");
 | 
			
		||||
const settings_streams = mock_module("settings_streams");
 | 
			
		||||
mock_module("subs", subs);
 | 
			
		||||
set_global("current_msg_list", {});
 | 
			
		||||
 | 
			
		||||
const stream_list = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_list").with(stream_list);
 | 
			
		||||
mock_module("stream_list", stream_list);
 | 
			
		||||
const peer_data = zrequire("peer_data");
 | 
			
		||||
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire, with_overrides} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire, with_overrides} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -24,11 +24,11 @@ const localStorage = set_global("localStorage", {
 | 
			
		||||
        ls_container.clear();
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
const compose_state = rewiremock("../../static/js/compose_state").with({});
 | 
			
		||||
rewiremock("../../static/js/markdown").with({
 | 
			
		||||
const compose_state = mock_module("compose_state");
 | 
			
		||||
mock_module("markdown", {
 | 
			
		||||
    apply_markdown: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/stream_data").with({
 | 
			
		||||
mock_module("stream_data", {
 | 
			
		||||
    get_color() {
 | 
			
		||||
        return "#FFFFFF";
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -10,7 +10,7 @@ const noop = () => {};
 | 
			
		||||
const _ListWidget = {
 | 
			
		||||
    create: () => ({init: noop}),
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/list_widget").with(_ListWidget);
 | 
			
		||||
mock_module("list_widget", _ListWidget);
 | 
			
		||||
const {DropdownListWidget: dropdown_list_widget} = zrequire("dropdown_list_widget");
 | 
			
		||||
 | 
			
		||||
const setup_zjquery_data = (name) => {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,11 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const MockDate = require("mockdate");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const local_message = rewiremock("../../static/js/local_message").with({});
 | 
			
		||||
const markdown = rewiremock("../../static/js/markdown").with({});
 | 
			
		||||
const local_message = mock_module("local_message");
 | 
			
		||||
const markdown = mock_module("markdown");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const fake_now = 555;
 | 
			
		||||
@@ -17,17 +17,17 @@ MockDate.set(new Date(fake_now * 1000));
 | 
			
		||||
let disparities = [];
 | 
			
		||||
let messages_to_rerender = [];
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui").with({
 | 
			
		||||
mock_module("ui", {
 | 
			
		||||
    show_failed_message_success: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/sent_messages").with({
 | 
			
		||||
mock_module("sent_messages", {
 | 
			
		||||
    mark_disparity: (local_id) => {
 | 
			
		||||
        disparities.push(local_id);
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_store").with({
 | 
			
		||||
mock_module("message_store", {
 | 
			
		||||
    get: () => ({failed_request: true}),
 | 
			
		||||
 | 
			
		||||
    update_booleans: () => {},
 | 
			
		||||
@@ -41,7 +41,7 @@ set_global("home_msg_list", {
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_list").with({});
 | 
			
		||||
mock_module("message_list");
 | 
			
		||||
set_global("current_msg_list", "");
 | 
			
		||||
 | 
			
		||||
const echo = zrequire("echo");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_scroll").with({
 | 
			
		||||
mock_module("message_scroll", {
 | 
			
		||||
    hide_loading_older: () => {},
 | 
			
		||||
 | 
			
		||||
    show_loading_older: () => {},
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const message_store = rewiremock("../../static/js/message_store").with({});
 | 
			
		||||
const message_store = mock_module("message_store");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const stream_data = zrequire("stream_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const ui_report = {
 | 
			
		||||
@@ -12,7 +12,7 @@ const ui_report = {
 | 
			
		||||
        ui_report.displayed_error = true;
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/ui_report").with(ui_report);
 | 
			
		||||
mock_module("ui_report", ui_report);
 | 
			
		||||
set_global("location", {
 | 
			
		||||
    protocol: "https:",
 | 
			
		||||
    host: "example.com",
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -13,23 +13,23 @@ set_global("location", {
 | 
			
		||||
});
 | 
			
		||||
set_global("to_$", () => window_stub);
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/search").with({
 | 
			
		||||
mock_module("search", {
 | 
			
		||||
    update_button_visibility: () => {},
 | 
			
		||||
});
 | 
			
		||||
set_global("document", "document-stub");
 | 
			
		||||
const history = set_global("history", {});
 | 
			
		||||
 | 
			
		||||
const admin = rewiremock("../../static/js/admin").with({});
 | 
			
		||||
const drafts = rewiremock("../../static/js/drafts").with({});
 | 
			
		||||
const floating_recipient_bar = rewiremock("../../static/js/floating_recipient_bar").with({});
 | 
			
		||||
const info_overlay = rewiremock("../../static/js/info_overlay").with({});
 | 
			
		||||
const message_viewport = rewiremock("../../static/js/message_viewport").with({});
 | 
			
		||||
const narrow = rewiremock("../../static/js/narrow").with({});
 | 
			
		||||
const overlays = rewiremock("../../static/js/overlays").with({});
 | 
			
		||||
const settings = rewiremock("../../static/js/settings").with({});
 | 
			
		||||
const subs = rewiremock("../../static/js/subs").with({});
 | 
			
		||||
const ui_util = rewiremock("../../static/js/ui_util").with({});
 | 
			
		||||
rewiremock("../../static/js/top_left_corner").with({
 | 
			
		||||
const admin = mock_module("admin");
 | 
			
		||||
const drafts = mock_module("drafts");
 | 
			
		||||
const floating_recipient_bar = mock_module("floating_recipient_bar");
 | 
			
		||||
const info_overlay = mock_module("info_overlay");
 | 
			
		||||
const message_viewport = mock_module("message_viewport");
 | 
			
		||||
const narrow = mock_module("narrow");
 | 
			
		||||
const overlays = mock_module("overlays");
 | 
			
		||||
const settings = mock_module("settings");
 | 
			
		||||
const subs = mock_module("subs");
 | 
			
		||||
const ui_util = mock_module("ui_util");
 | 
			
		||||
mock_module("top_left_corner", {
 | 
			
		||||
    handle_narrow_deactivated: () => {},
 | 
			
		||||
});
 | 
			
		||||
set_global("favicon", {});
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {
 | 
			
		||||
    rewiremock,
 | 
			
		||||
    mock_module,
 | 
			
		||||
    set_global,
 | 
			
		||||
    with_field,
 | 
			
		||||
    with_overrides,
 | 
			
		||||
@@ -18,7 +18,7 @@ const popovers = {
 | 
			
		||||
    user_sidebar_popped: () => false,
 | 
			
		||||
    user_info_popped: () => false,
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/popovers").with(popovers);
 | 
			
		||||
mock_module("popovers", popovers);
 | 
			
		||||
const overlays = {
 | 
			
		||||
    is_active: () => false,
 | 
			
		||||
    settings_open: () => false,
 | 
			
		||||
@@ -28,9 +28,9 @@ const overlays = {
 | 
			
		||||
    info_overlay_open: () => false,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/overlays").with(overlays);
 | 
			
		||||
mock_module("overlays", overlays);
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_popover").with({
 | 
			
		||||
mock_module("stream_popover", {
 | 
			
		||||
    stream_popped: () => false,
 | 
			
		||||
    topic_popped: () => false,
 | 
			
		||||
    all_messages_popped: () => false,
 | 
			
		||||
@@ -40,8 +40,8 @@ rewiremock("../../static/js/stream_popover").with({
 | 
			
		||||
const emoji_picker = {
 | 
			
		||||
    reactions_popped: () => false,
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/emoji_picker").with(emoji_picker);
 | 
			
		||||
rewiremock("../../static/js/hotspots").with({
 | 
			
		||||
mock_module("emoji_picker", emoji_picker);
 | 
			
		||||
mock_module("hotspots", {
 | 
			
		||||
    is_open: () => false,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -49,7 +49,7 @@ const gear_menu = {
 | 
			
		||||
    is_open: () => false,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/gear_menu").with(gear_menu);
 | 
			
		||||
mock_module("gear_menu", gear_menu);
 | 
			
		||||
// Important note on these tests:
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
@@ -77,30 +77,30 @@ const page_params = set_global("page_params", {});
 | 
			
		||||
// jQuery stuff should go away if we make an initialize() method.
 | 
			
		||||
set_global("document", "document-stub");
 | 
			
		||||
 | 
			
		||||
const compose_actions = rewiremock("../../static/js/compose_actions").with({});
 | 
			
		||||
const condense = rewiremock("../../static/js/condense").with({});
 | 
			
		||||
const drafts = rewiremock("../../static/js/drafts").with({});
 | 
			
		||||
const compose_actions = mock_module("compose_actions");
 | 
			
		||||
const condense = mock_module("condense");
 | 
			
		||||
const drafts = mock_module("drafts");
 | 
			
		||||
 | 
			
		||||
const hashchange = {
 | 
			
		||||
    in_recent_topics_hash: () => false,
 | 
			
		||||
};
 | 
			
		||||
const lightbox = rewiremock("../../static/js/lightbox").with({});
 | 
			
		||||
const list_util = rewiremock("../../static/js/list_util").with({});
 | 
			
		||||
const message_edit = rewiremock("../../static/js/message_edit").with({});
 | 
			
		||||
const muting_ui = rewiremock("../../static/js/muting_ui").with({});
 | 
			
		||||
const narrow = rewiremock("../../static/js/narrow").with({});
 | 
			
		||||
const navigate = rewiremock("../../static/js/navigate").with({});
 | 
			
		||||
const reactions = rewiremock("../../static/js/reactions").with({});
 | 
			
		||||
const search = rewiremock("../../static/js/search").with({});
 | 
			
		||||
const stream_list = rewiremock("../../static/js/stream_list").with({});
 | 
			
		||||
rewiremock("../../static/js/hashchange").with(hashchange);
 | 
			
		||||
const lightbox = mock_module("lightbox");
 | 
			
		||||
const list_util = mock_module("list_util");
 | 
			
		||||
const message_edit = mock_module("message_edit");
 | 
			
		||||
const muting_ui = mock_module("muting_ui");
 | 
			
		||||
const narrow = mock_module("narrow");
 | 
			
		||||
const navigate = mock_module("navigate");
 | 
			
		||||
const reactions = mock_module("reactions");
 | 
			
		||||
const search = mock_module("search");
 | 
			
		||||
const stream_list = mock_module("stream_list");
 | 
			
		||||
mock_module("hashchange", hashchange);
 | 
			
		||||
 | 
			
		||||
const subs = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/recent_topics").with({
 | 
			
		||||
mock_module("recent_topics", {
 | 
			
		||||
    is_visible: () => false,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/subs").with(subs);
 | 
			
		||||
mock_module("subs", subs);
 | 
			
		||||
set_global("current_msg_list", {
 | 
			
		||||
    empty() {
 | 
			
		||||
        return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -11,7 +11,7 @@ set_global("document", {});
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
const example_img_link = "http://example.com/example.png";
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui_util").with({
 | 
			
		||||
mock_module("ui_util", {
 | 
			
		||||
    place_caret_at_end: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,22 +2,22 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
set_global("Image", class Image {});
 | 
			
		||||
rewiremock("../../static/js/overlays").with({
 | 
			
		||||
mock_module("overlays", {
 | 
			
		||||
    close_overlay: () => {},
 | 
			
		||||
 | 
			
		||||
    close_active: () => {},
 | 
			
		||||
    open_overlay: () => {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/popovers").with({
 | 
			
		||||
mock_module("popovers", {
 | 
			
		||||
    hide_all: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const message_store = rewiremock("../../static/js/message_store").with({});
 | 
			
		||||
const message_store = mock_module("message_store");
 | 
			
		||||
const rows = zrequire("rows");
 | 
			
		||||
 | 
			
		||||
const lightbox = zrequire("lightbox");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
// We need these stubs to get by instanceof checks.
 | 
			
		||||
@@ -16,7 +16,7 @@ function Element() {
 | 
			
		||||
set_global("Element", Element);
 | 
			
		||||
const ui = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui").with(ui);
 | 
			
		||||
mock_module("ui", ui);
 | 
			
		||||
// We only need very simple jQuery wrappers for when the
 | 
			
		||||
 | 
			
		||||
// "real" code wraps html or sets up click handlers.
 | 
			
		||||
 
 | 
			
		||||
@@ -2,21 +2,21 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const condense = rewiremock("../../static/js/condense").with({});
 | 
			
		||||
const message_edit = rewiremock("../../static/js/message_edit").with({});
 | 
			
		||||
const message_list = rewiremock("../../static/js/message_list").with({});
 | 
			
		||||
const notifications = rewiremock("../../static/js/notifications").with({});
 | 
			
		||||
const condense = mock_module("condense");
 | 
			
		||||
const message_edit = mock_module("message_edit");
 | 
			
		||||
const message_list = mock_module("message_list");
 | 
			
		||||
const notifications = mock_module("notifications");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const pm_list = rewiremock("../../static/js/pm_list").with({});
 | 
			
		||||
const stream_list = rewiremock("../../static/js/stream_list").with({});
 | 
			
		||||
const pm_list = mock_module("pm_list");
 | 
			
		||||
const stream_list = mock_module("stream_list");
 | 
			
		||||
set_global("current_msg_list", {});
 | 
			
		||||
 | 
			
		||||
const unread_ui = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/unread_ui").with(unread_ui);
 | 
			
		||||
mock_module("unread_ui", unread_ui);
 | 
			
		||||
const message_events = zrequire("message_events");
 | 
			
		||||
 | 
			
		||||
const message_store = zrequire("message_store");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -15,25 +15,25 @@ const noop = () => {};
 | 
			
		||||
function MessageListView() {
 | 
			
		||||
    return {};
 | 
			
		||||
}
 | 
			
		||||
rewiremock("../../static/js/message_list_view").with({
 | 
			
		||||
mock_module("message_list_view", {
 | 
			
		||||
    MessageListView,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/recent_topics").with({
 | 
			
		||||
mock_module("recent_topics", {
 | 
			
		||||
    process_messages: noop,
 | 
			
		||||
});
 | 
			
		||||
// Still required for page_params.initial_pointer
 | 
			
		||||
set_global("page_params", {});
 | 
			
		||||
rewiremock("../../static/js/ui_report").with({
 | 
			
		||||
mock_module("ui_report", {
 | 
			
		||||
    hide_error: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const message_store = rewiremock("../../static/js/message_store").with({});
 | 
			
		||||
const message_util = rewiremock("../../static/js/message_util").with({});
 | 
			
		||||
const pm_list = rewiremock("../../static/js/pm_list").with({});
 | 
			
		||||
const server_events = rewiremock("../../static/js/server_events").with({});
 | 
			
		||||
rewiremock("../../static/js/message_scroll").with({
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const message_store = mock_module("message_store");
 | 
			
		||||
const message_util = mock_module("message_util");
 | 
			
		||||
const pm_list = mock_module("pm_list");
 | 
			
		||||
const server_events = mock_module("server_events");
 | 
			
		||||
mock_module("message_scroll", {
 | 
			
		||||
    show_loading_older: noop,
 | 
			
		||||
    hide_loading_older: noop,
 | 
			
		||||
    show_loading_newer: noop,
 | 
			
		||||
@@ -46,7 +46,7 @@ const stream_list = {
 | 
			
		||||
    maybe_scroll_narrow_into_view: () => {},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_list").with(stream_list);
 | 
			
		||||
mock_module("stream_list", stream_list);
 | 
			
		||||
const message_fetch = zrequire("message_fetch");
 | 
			
		||||
 | 
			
		||||
const {Filter} = zrequire("../js/filter");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,19 +2,19 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/starred_messages").with({
 | 
			
		||||
mock_module("starred_messages", {
 | 
			
		||||
    add: () => {},
 | 
			
		||||
 | 
			
		||||
    remove: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const ui = rewiremock("../../static/js/ui").with({});
 | 
			
		||||
const ui = mock_module("ui");
 | 
			
		||||
const channel = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/channel").with(channel);
 | 
			
		||||
mock_module("channel", channel);
 | 
			
		||||
const message_flags = zrequire("message_flags");
 | 
			
		||||
 | 
			
		||||
run_test("starred", () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
@@ -13,7 +13,7 @@ const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const noop = function () {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/filter").with({
 | 
			
		||||
mock_module("filter", {
 | 
			
		||||
    Filter: noop,
 | 
			
		||||
});
 | 
			
		||||
set_global("document", {
 | 
			
		||||
@@ -24,8 +24,8 @@ set_global("document", {
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const narrow_state = rewiremock("../../static/js/narrow_state").with({});
 | 
			
		||||
const stream_data = rewiremock("../../static/js/stream_data").with({});
 | 
			
		||||
const narrow_state = mock_module("narrow_state");
 | 
			
		||||
const stream_data = mock_module("stream_data");
 | 
			
		||||
 | 
			
		||||
const muting = zrequire("muting");
 | 
			
		||||
const {MessageList} = zrequire("message_list");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
set_global("document", "document-stub");
 | 
			
		||||
@@ -16,7 +16,7 @@ const page_params = set_global("page_params", {
 | 
			
		||||
});
 | 
			
		||||
set_global("home_msg_list", "stub");
 | 
			
		||||
// timerender calls setInterval when imported
 | 
			
		||||
rewiremock("../../static/js/timerender").with({
 | 
			
		||||
mock_module("timerender", {
 | 
			
		||||
    render_date(time1, time2) {
 | 
			
		||||
        if (time2 === undefined) {
 | 
			
		||||
            return [{outerHTML: String(time1.getTime())}];
 | 
			
		||||
@@ -31,7 +31,7 @@ rewiremock("../../static/js/timerender").with({
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/rows").with({
 | 
			
		||||
mock_module("rows", {
 | 
			
		||||
    get_table() {
 | 
			
		||||
        return {
 | 
			
		||||
            children() {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
@@ -10,11 +10,11 @@ const noop = () => {};
 | 
			
		||||
 | 
			
		||||
set_global("document", "document-stub");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_topic_history").with({
 | 
			
		||||
mock_module("stream_topic_history", {
 | 
			
		||||
    add_message: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/recent_senders").with({
 | 
			
		||||
mock_module("recent_senders", {
 | 
			
		||||
    process_message_for_senders: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -10,7 +10,7 @@ set_global("page_params", {
 | 
			
		||||
    stop_words: ["what", "about"],
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const stream_topic_history = rewiremock("../../static/js/stream_topic_history").with({});
 | 
			
		||||
const stream_topic_history = mock_module("stream_topic_history");
 | 
			
		||||
const hash_util = zrequire("hash_util");
 | 
			
		||||
 | 
			
		||||
const compose_state = zrequire("compose_state");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,18 +2,18 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
mock_module("resize", {
 | 
			
		||||
    resize_stream_filters_container: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const compose = rewiremock("../../static/js/compose").with({});
 | 
			
		||||
const compose_actions = rewiremock("../../static/js/compose_actions").with({});
 | 
			
		||||
const hashchange = rewiremock("../../static/js/hashchange").with({});
 | 
			
		||||
const message_fetch = rewiremock("../../static/js/message_fetch").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const compose = mock_module("compose");
 | 
			
		||||
const compose_actions = mock_module("compose_actions");
 | 
			
		||||
const hashchange = mock_module("hashchange");
 | 
			
		||||
const message_fetch = mock_module("message_fetch");
 | 
			
		||||
set_global("current_msg_list", {});
 | 
			
		||||
set_global("home_msg_list", {});
 | 
			
		||||
 | 
			
		||||
@@ -22,17 +22,17 @@ const message_list = {
 | 
			
		||||
        message_list.narrowed = value;
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
const message_scroll = rewiremock("../../static/js/message_scroll").with({});
 | 
			
		||||
const message_view_header = rewiremock("../../static/js/message_view_header").with({});
 | 
			
		||||
const notifications = rewiremock("../../static/js/notifications").with({});
 | 
			
		||||
const search = rewiremock("../../static/js/search").with({});
 | 
			
		||||
const stream_list = rewiremock("../../static/js/stream_list").with({});
 | 
			
		||||
const top_left_corner = rewiremock("../../static/js/top_left_corner").with({});
 | 
			
		||||
const typing_events = rewiremock("../../static/js/typing_events").with({});
 | 
			
		||||
const ui_util = rewiremock("../../static/js/ui_util").with({});
 | 
			
		||||
const unread_ops = rewiremock("../../static/js/unread_ops").with({});
 | 
			
		||||
rewiremock("../../static/js/message_list").with(message_list);
 | 
			
		||||
rewiremock("../../static/js/recent_topics").with({
 | 
			
		||||
const message_scroll = mock_module("message_scroll");
 | 
			
		||||
const message_view_header = mock_module("message_view_header");
 | 
			
		||||
const notifications = mock_module("notifications");
 | 
			
		||||
const search = mock_module("search");
 | 
			
		||||
const stream_list = mock_module("stream_list");
 | 
			
		||||
const top_left_corner = mock_module("top_left_corner");
 | 
			
		||||
const typing_events = mock_module("typing_events");
 | 
			
		||||
const ui_util = mock_module("ui_util");
 | 
			
		||||
const unread_ops = mock_module("unread_ops");
 | 
			
		||||
mock_module("message_list", message_list);
 | 
			
		||||
mock_module("recent_topics", {
 | 
			
		||||
    hide: () => {},
 | 
			
		||||
    is_visible: () => {},
 | 
			
		||||
});
 | 
			
		||||
@@ -46,7 +46,7 @@ set_global("setTimeout", (f, t) => {
 | 
			
		||||
    f();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/muting").with({
 | 
			
		||||
mock_module("muting", {
 | 
			
		||||
    is_topic_muted: () => false,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,12 +2,12 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const message_list = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_list").with(message_list);
 | 
			
		||||
mock_module("message_list", message_list);
 | 
			
		||||
const {Filter} = zrequire("../js/filter");
 | 
			
		||||
 | 
			
		||||
const {MessageListData} = zrequire("../js/message_list_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const message_store = rewiremock("../../static/js/message_store").with({});
 | 
			
		||||
rewiremock("../../static/js/muting").with({
 | 
			
		||||
const message_store = mock_module("message_store");
 | 
			
		||||
mock_module("muting", {
 | 
			
		||||
    is_topic_muted: () => false,
 | 
			
		||||
});
 | 
			
		||||
set_global("page_params", {});
 | 
			
		||||
 
 | 
			
		||||
@@ -6,10 +6,10 @@ const {parseISO} = require("date-fns");
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
const MockDate = require("mockdate");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const message_store = rewiremock("../../static/js/message_store").with({});
 | 
			
		||||
const message_store = mock_module("message_store");
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,14 +2,14 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const reload_state = {
 | 
			
		||||
    is_in_progress: () => false,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/reload_state").with(reload_state);
 | 
			
		||||
mock_module("reload_state", reload_state);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const me = {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,27 +2,27 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const narrow_state = rewiremock("../../static/js/narrow_state").with({});
 | 
			
		||||
const unread = rewiremock("../../static/js/unread").with({});
 | 
			
		||||
const unread_ui = rewiremock("../../static/js/unread_ui").with({});
 | 
			
		||||
rewiremock("../../static/js/stream_popover").with({
 | 
			
		||||
const narrow_state = mock_module("narrow_state");
 | 
			
		||||
const unread = mock_module("unread");
 | 
			
		||||
const unread_ui = mock_module("unread_ui");
 | 
			
		||||
mock_module("stream_popover", {
 | 
			
		||||
    hide_topic_popover() {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/ui").with({
 | 
			
		||||
mock_module("ui", {
 | 
			
		||||
    get_content_element: (element) => element,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const vdom = {
 | 
			
		||||
    render: () => "fake-dom-for-pm-list",
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/vdom").with(vdom);
 | 
			
		||||
mock_module("vdom", vdom);
 | 
			
		||||
const pm_list_dom = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/pm_list_dom").with(pm_list_dom);
 | 
			
		||||
mock_module("pm_list_dom", pm_list_dom);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const pm_conversations = zrequire("pm_conversations");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -17,14 +17,14 @@ set_global("page_params", {
 | 
			
		||||
});
 | 
			
		||||
const rows = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/emoji_picker").with({
 | 
			
		||||
mock_module("emoji_picker", {
 | 
			
		||||
    hide_emoji_popover: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/message_viewport").with({
 | 
			
		||||
mock_module("message_viewport", {
 | 
			
		||||
    height: () => 500,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/rows").with(rows);
 | 
			
		||||
rewiremock("../../static/js/stream_popover").with({
 | 
			
		||||
mock_module("rows", rows);
 | 
			
		||||
mock_module("stream_popover", {
 | 
			
		||||
    hide_stream_popover: noop,
 | 
			
		||||
    hide_topic_popover: noop,
 | 
			
		||||
    hide_all_messages_popover: noop,
 | 
			
		||||
@@ -34,7 +34,7 @@ rewiremock("../../static/js/stream_popover").with({
 | 
			
		||||
 | 
			
		||||
const stream_data = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_data").with(stream_data);
 | 
			
		||||
mock_module("stream_data", stream_data);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const user_status = zrequire("user_status");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,15 +2,15 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const server_events = rewiremock("../../static/js/server_events").with({});
 | 
			
		||||
const server_events = mock_module("server_events");
 | 
			
		||||
const reload_state = {
 | 
			
		||||
    is_in_progress: () => false,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/reload_state").with(reload_state);
 | 
			
		||||
mock_module("reload_state", reload_state);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const presence = zrequire("presence");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
@@ -15,12 +15,12 @@ set_global("page_params", {
 | 
			
		||||
    user_id: alice_user_id,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const emoji_picker = {
 | 
			
		||||
    hide_emoji_popover() {},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/emoji_picker").with(emoji_picker);
 | 
			
		||||
mock_module("emoji_picker", emoji_picker);
 | 
			
		||||
const message = {
 | 
			
		||||
    id: 1001,
 | 
			
		||||
    reactions: [
 | 
			
		||||
@@ -59,7 +59,7 @@ const message_store = {
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_store").with(message_store);
 | 
			
		||||
mock_module("message_store", message_store);
 | 
			
		||||
set_global("current_msg_list", {
 | 
			
		||||
    selected_message() {
 | 
			
		||||
        return {sent_by_me: true};
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,13 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
let next_id = 0;
 | 
			
		||||
const messages = [];
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_store").with({
 | 
			
		||||
mock_module("message_store", {
 | 
			
		||||
    get: (msg_id) => messages[msg_id - 1],
 | 
			
		||||
});
 | 
			
		||||
const message_list = {
 | 
			
		||||
@@ -19,7 +19,7 @@ const message_list = {
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_list").with(message_list);
 | 
			
		||||
mock_module("message_list", message_list);
 | 
			
		||||
const rs = zrequire("recent_senders");
 | 
			
		||||
 | 
			
		||||
zrequire("message_util.js");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,28 +3,28 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
rewiremock("../../static/js/top_left_corner").with({
 | 
			
		||||
mock_module("top_left_corner", {
 | 
			
		||||
    narrow_to_recent_topics: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/stream_list").with({
 | 
			
		||||
mock_module("stream_list", {
 | 
			
		||||
    handle_narrow_deactivated: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/compose_actions").with({
 | 
			
		||||
mock_module("compose_actions", {
 | 
			
		||||
    cancel: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/narrow").with({
 | 
			
		||||
mock_module("narrow", {
 | 
			
		||||
    set_narrow_title: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/message_view_header").with({
 | 
			
		||||
mock_module("message_view_header", {
 | 
			
		||||
    render_title_area: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/timerender").with({
 | 
			
		||||
mock_module("timerender", {
 | 
			
		||||
    last_seen_status_from_date: () => "Just now",
 | 
			
		||||
 | 
			
		||||
    get_full_datetime: () => ({
 | 
			
		||||
@@ -32,7 +32,7 @@ rewiremock("../../static/js/timerender").with({
 | 
			
		||||
        time: "time",
 | 
			
		||||
    }),
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/unread").with({
 | 
			
		||||
mock_module("unread", {
 | 
			
		||||
    unread_topic_counter: {
 | 
			
		||||
        get: (stream_id, topic) => {
 | 
			
		||||
            if (stream_id === 1 && topic === "topic-1") {
 | 
			
		||||
@@ -43,12 +43,12 @@ rewiremock("../../static/js/unread").with({
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/hash_util").with({
 | 
			
		||||
mock_module("hash_util", {
 | 
			
		||||
    by_stream_uri: () => "https://www.example.com",
 | 
			
		||||
 | 
			
		||||
    by_stream_topic_uri: () => "https://www.example.com",
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/recent_senders").with({
 | 
			
		||||
mock_module("recent_senders", {
 | 
			
		||||
    get_topic_recent_senders: () => [1, 2],
 | 
			
		||||
});
 | 
			
		||||
const ListWidget = {
 | 
			
		||||
@@ -77,10 +77,10 @@ const ListWidget = {
 | 
			
		||||
    hard_redraw: noop,
 | 
			
		||||
    render_item: (item) => ListWidget.modifier(item),
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/drafts").with({
 | 
			
		||||
mock_module("drafts", {
 | 
			
		||||
    update_draft: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/list_widget").with(ListWidget);
 | 
			
		||||
mock_module("list_widget", ListWidget);
 | 
			
		||||
 | 
			
		||||
const ls_container = new Map();
 | 
			
		||||
set_global("localStorage", {
 | 
			
		||||
@@ -119,7 +119,7 @@ const topic8 = "topic-8";
 | 
			
		||||
const topic9 = "topic-9";
 | 
			
		||||
const topic10 = "topic-10";
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/muting").with({
 | 
			
		||||
mock_module("muting", {
 | 
			
		||||
    is_topic_muted: (stream_id, topic) => {
 | 
			
		||||
        if (stream_id === stream1 && topic === topic7) {
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -142,11 +142,11 @@ const message_list = {
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/message_list").with(message_list);
 | 
			
		||||
rewiremock("../../static/js/message_store").with({
 | 
			
		||||
mock_module("message_list", message_list);
 | 
			
		||||
mock_module("message_store", {
 | 
			
		||||
    get: (msg_id) => messages[msg_id - 1],
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/stream_data").with({
 | 
			
		||||
mock_module("stream_data", {
 | 
			
		||||
    get_sub_by_id: (stream) => {
 | 
			
		||||
        if (stream === stream5) {
 | 
			
		||||
            // No data is available for deactivated streams
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/rtl").with({
 | 
			
		||||
mock_module("rtl", {
 | 
			
		||||
    get_direction: () => "ltr",
 | 
			
		||||
});
 | 
			
		||||
const page_params = set_global("page_params", {emojiset: "apple"});
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui").with({
 | 
			
		||||
mock_module("ui", {
 | 
			
		||||
    get_scroll_element: (element) => element,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -15,15 +15,15 @@ const noop = () => {};
 | 
			
		||||
const narrow_state = {
 | 
			
		||||
    filter: () => false,
 | 
			
		||||
};
 | 
			
		||||
const narrow = rewiremock("../../static/js/narrow").with({});
 | 
			
		||||
const search_suggestion = rewiremock("../../static/js/search_suggestion").with({});
 | 
			
		||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
 | 
			
		||||
rewiremock("../../static/js/search_pill_widget").with({
 | 
			
		||||
const narrow = mock_module("narrow");
 | 
			
		||||
const search_suggestion = mock_module("search_suggestion");
 | 
			
		||||
mock_module("narrow_state", narrow_state);
 | 
			
		||||
mock_module("search_pill_widget", {
 | 
			
		||||
    widget: {
 | 
			
		||||
        getByID: () => true,
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/ui_util").with({
 | 
			
		||||
mock_module("ui_util", {
 | 
			
		||||
    change_tab_to: noop,
 | 
			
		||||
    place_caret_at_end: noop,
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -12,16 +12,16 @@ set_global("page_params", {
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
 | 
			
		||||
const narrow = rewiremock("../../static/js/narrow").with({});
 | 
			
		||||
const narrow_state = rewiremock("../../static/js/narrow_state").with({});
 | 
			
		||||
const search_suggestion = rewiremock("../../static/js/search_suggestion").with({});
 | 
			
		||||
rewiremock("../../static/js/ui_util").with({
 | 
			
		||||
const narrow = mock_module("narrow");
 | 
			
		||||
const narrow_state = mock_module("narrow_state");
 | 
			
		||||
const search_suggestion = mock_module("search_suggestion");
 | 
			
		||||
mock_module("ui_util", {
 | 
			
		||||
    change_tab_to: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const Filter = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/filter").with({
 | 
			
		||||
mock_module("filter", {
 | 
			
		||||
    Filter,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,14 +2,14 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {
 | 
			
		||||
    search_pills_enabled: true,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_store").with({
 | 
			
		||||
mock_module("message_store", {
 | 
			
		||||
    user_ids: () => [],
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,13 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {
 | 
			
		||||
    search_pills_enabled: false,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/message_store").with({
 | 
			
		||||
mock_module("message_store", {
 | 
			
		||||
    user_ids: () => [],
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
@@ -16,8 +16,8 @@ set_global("document", {
 | 
			
		||||
});
 | 
			
		||||
set_global("addEventListener", noop);
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
rewiremock("../../static/js/reload_state").with({
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
mock_module("reload_state", {
 | 
			
		||||
    is_in_progress() {
 | 
			
		||||
        return false;
 | 
			
		||||
    },
 | 
			
		||||
@@ -33,7 +33,7 @@ set_global("page_params", {test_suite: false});
 | 
			
		||||
// we also directly write to pointer
 | 
			
		||||
set_global("pointer", {});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui_report").with({
 | 
			
		||||
mock_module("ui_report", {
 | 
			
		||||
    hide_error() {
 | 
			
		||||
        return false;
 | 
			
		||||
    },
 | 
			
		||||
@@ -42,13 +42,13 @@ rewiremock("../../static/js/ui_report").with({
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_events").with({
 | 
			
		||||
mock_module("stream_events", {
 | 
			
		||||
    update_property() {
 | 
			
		||||
        throw new Error("subs update error");
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const message_events = rewiremock("../../static/js/message_events").with({
 | 
			
		||||
const message_events = mock_module("message_events", {
 | 
			
		||||
    insert_new_messages() {
 | 
			
		||||
        throw new Error("insert error");
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -27,7 +27,7 @@ const bot_data_params = {
 | 
			
		||||
    ],
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const avatar = rewiremock("../../static/js/avatar").with({});
 | 
			
		||||
const avatar = mock_module("avatar");
 | 
			
		||||
function ClipboardJS(sel) {
 | 
			
		||||
    assert.equal(sel, "#copy_zuliprc");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const upload_widget = rewiremock("../../static/js/upload_widget").with({});
 | 
			
		||||
const upload_widget = mock_module("upload_widget");
 | 
			
		||||
const settings_emoji = zrequire("settings_emoji");
 | 
			
		||||
 | 
			
		||||
run_test("build_emoji_upload_widget", () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,13 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const muting_ui = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/muting_ui").with(muting_ui);
 | 
			
		||||
mock_module("muting_ui", muting_ui);
 | 
			
		||||
const settings_muting = zrequire("settings_muting");
 | 
			
		||||
 | 
			
		||||
const stream_data = zrequire("stream_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -37,10 +37,10 @@ const page_params = set_global("page_params", {
 | 
			
		||||
    realm_authentication_methods: {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const realm_icon = rewiremock("../../static/js/realm_icon").with({});
 | 
			
		||||
const realm_icon = mock_module("realm_icon");
 | 
			
		||||
const channel = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/channel").with(channel);
 | 
			
		||||
mock_module("channel", channel);
 | 
			
		||||
stub_templates((name, data) => {
 | 
			
		||||
    if (name === "settings/admin_realm_domains_list") {
 | 
			
		||||
        assert(data.realm_domain.domain);
 | 
			
		||||
@@ -51,7 +51,7 @@ stub_templates((name, data) => {
 | 
			
		||||
 | 
			
		||||
const overlays = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/overlays").with(overlays);
 | 
			
		||||
mock_module("overlays", overlays);
 | 
			
		||||
const _ui_report = {
 | 
			
		||||
    success(msg, elem) {
 | 
			
		||||
        elem.val(msg);
 | 
			
		||||
@@ -69,9 +69,9 @@ const _ListWidget = {
 | 
			
		||||
set_global("csrf_token", "token-stub");
 | 
			
		||||
set_global("FormData", _FormData);
 | 
			
		||||
set_global("jQuery", _jQuery);
 | 
			
		||||
rewiremock("../../static/js/list_widget").with(_ListWidget);
 | 
			
		||||
rewiremock("../../static/js/loading").with(_loading);
 | 
			
		||||
rewiremock("../../static/js/ui_report").with(_ui_report);
 | 
			
		||||
mock_module("list_widget", _ListWidget);
 | 
			
		||||
mock_module("loading", _loading);
 | 
			
		||||
mock_module("ui_report", _ui_report);
 | 
			
		||||
 | 
			
		||||
const settings_config = zrequire("settings_config");
 | 
			
		||||
const settings_bots = zrequire("settings_bots");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,14 +3,14 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const loading = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/loading").with(loading);
 | 
			
		||||
mock_module("loading", loading);
 | 
			
		||||
const SHORT_TEXT_ID = 1;
 | 
			
		||||
 | 
			
		||||
const CHOICE_ID = 3;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,13 @@ const {strict: assert} = require("assert");
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const confirm_dialog = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/confirm_dialog").with(confirm_dialog);
 | 
			
		||||
mock_module("confirm_dialog", confirm_dialog);
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
 | 
			
		||||
const pills = {
 | 
			
		||||
@@ -20,23 +20,23 @@ const pills = {
 | 
			
		||||
 | 
			
		||||
let create_item_handler;
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const typeahead_helper = rewiremock("../../static/js/typeahead_helper").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const typeahead_helper = mock_module("typeahead_helper");
 | 
			
		||||
 | 
			
		||||
const user_groups = {
 | 
			
		||||
    get_user_group_from_id: noop,
 | 
			
		||||
    remove: noop,
 | 
			
		||||
    add: noop,
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/user_groups").with(user_groups);
 | 
			
		||||
mock_module("user_groups", user_groups);
 | 
			
		||||
const ui_report = {};
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
rewiremock("../../static/js/ui_report").with(ui_report);
 | 
			
		||||
mock_module("ui_report", ui_report);
 | 
			
		||||
 | 
			
		||||
const input_pill = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/input_pill").with(input_pill);
 | 
			
		||||
mock_module("input_pill", input_pill);
 | 
			
		||||
const user_pill = zrequire("user_pill");
 | 
			
		||||
 | 
			
		||||
const settings_user_groups = zrequire("settings_user_groups");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -11,19 +11,19 @@ const noop = () => {};
 | 
			
		||||
stub_templates(() => noop);
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const typeahead_helper = rewiremock("../../static/js/typeahead_helper").with({});
 | 
			
		||||
rewiremock("../../static/js/hash_util").with({
 | 
			
		||||
const typeahead_helper = mock_module("typeahead_helper");
 | 
			
		||||
mock_module("hash_util", {
 | 
			
		||||
    stream_edit_uri: noop,
 | 
			
		||||
    by_stream_uri: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/hashchange").with({update_browser_history: noop});
 | 
			
		||||
rewiremock("../../static/js/list_widget").with({
 | 
			
		||||
mock_module("hashchange", {update_browser_history: noop});
 | 
			
		||||
mock_module("list_widget", {
 | 
			
		||||
    create: () => ({init: noop}),
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/settings_notifications").with({
 | 
			
		||||
mock_module("settings_notifications", {
 | 
			
		||||
    get_notifications_table_row_data: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/stream_color").with({
 | 
			
		||||
mock_module("stream_color", {
 | 
			
		||||
    set_colorpicker_color: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -31,7 +31,7 @@ const ui = {
 | 
			
		||||
    get_scroll_element: noop,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/ui").with(ui);
 | 
			
		||||
mock_module("ui", ui);
 | 
			
		||||
const peer_data = zrequire("peer_data");
 | 
			
		||||
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
@@ -11,29 +11,29 @@ const noop = () => {};
 | 
			
		||||
const _settings_notifications = {
 | 
			
		||||
    update_page: () => {},
 | 
			
		||||
};
 | 
			
		||||
const color_data = rewiremock("../../static/js/color_data").with({});
 | 
			
		||||
const message_util = rewiremock("../../static/js/message_util").with({});
 | 
			
		||||
const stream_color = rewiremock("../../static/js/stream_color").with({});
 | 
			
		||||
const stream_list = rewiremock("../../static/js/stream_list").with({});
 | 
			
		||||
const stream_muting = rewiremock("../../static/js/stream_muting").with({});
 | 
			
		||||
rewiremock("../../static/js/message_list").with({
 | 
			
		||||
const color_data = mock_module("color_data");
 | 
			
		||||
const message_util = mock_module("message_util");
 | 
			
		||||
const stream_color = mock_module("stream_color");
 | 
			
		||||
const stream_list = mock_module("stream_list");
 | 
			
		||||
const stream_muting = mock_module("stream_muting");
 | 
			
		||||
mock_module("message_list", {
 | 
			
		||||
    all: {
 | 
			
		||||
        all_messages() {
 | 
			
		||||
            return ["msg"];
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/recent_topics").with({
 | 
			
		||||
mock_module("recent_topics", {
 | 
			
		||||
    complete_rerender: () => {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/settings_notifications").with(_settings_notifications);
 | 
			
		||||
mock_module("settings_notifications", _settings_notifications);
 | 
			
		||||
set_global("current_msg_list", {});
 | 
			
		||||
 | 
			
		||||
const subs = {
 | 
			
		||||
    update_settings_for_subscribed: noop,
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/overlays").with({streams_open: () => true});
 | 
			
		||||
rewiremock("../../static/js/subs").with(subs);
 | 
			
		||||
mock_module("overlays", {streams_open: () => true});
 | 
			
		||||
mock_module("subs", subs);
 | 
			
		||||
 | 
			
		||||
const peer_data = zrequire("peer_data");
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -16,12 +16,12 @@ const page_params = set_global("page_params", {
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
 | 
			
		||||
const narrow_state = rewiremock("../../static/js/narrow_state").with({});
 | 
			
		||||
const topic_list = rewiremock("../../static/js/topic_list").with({});
 | 
			
		||||
rewiremock("../../static/js/keydown_util").with({
 | 
			
		||||
const narrow_state = mock_module("narrow_state");
 | 
			
		||||
const topic_list = mock_module("topic_list");
 | 
			
		||||
mock_module("keydown_util", {
 | 
			
		||||
    handle: noop,
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/ui").with({get_scroll_element: (element) => element});
 | 
			
		||||
mock_module("ui", {get_scroll_element: (element) => element});
 | 
			
		||||
 | 
			
		||||
const {Filter} = zrequire("../js/filter");
 | 
			
		||||
const stream_sort = zrequire("stream_sort");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -11,16 +11,16 @@ const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
mock_module("resize", {
 | 
			
		||||
    resize_page_components: noop,
 | 
			
		||||
 | 
			
		||||
    resize_stream_filters_container: noop,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const popovers = rewiremock("../../static/js/popovers").with({});
 | 
			
		||||
const popovers = mock_module("popovers");
 | 
			
		||||
const stream_popover = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/stream_popover").with(stream_popover);
 | 
			
		||||
mock_module("stream_popover", stream_popover);
 | 
			
		||||
const stream_list = zrequire("stream_list");
 | 
			
		||||
 | 
			
		||||
function expand_sidebar() {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,12 +2,12 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const message_list = rewiremock("../../static/js/message_list").with({});
 | 
			
		||||
const message_util = rewiremock("../../static/js/message_util").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const message_list = mock_module("message_list");
 | 
			
		||||
const message_util = mock_module("message_util");
 | 
			
		||||
 | 
			
		||||
const unread = zrequire("unread");
 | 
			
		||||
const stream_data = zrequire("stream_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,15 +2,15 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const widgetize = rewiremock("../../static/js/widgetize").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const widgetize = mock_module("widgetize");
 | 
			
		||||
 | 
			
		||||
const message_store = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_store").with(message_store);
 | 
			
		||||
mock_module("message_store", message_store);
 | 
			
		||||
const submessage = zrequire("submessage");
 | 
			
		||||
 | 
			
		||||
run_test("get_message_events", () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {stub_templates} = require("../zjsunit/handlebars");
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -11,7 +11,7 @@ const ui = {
 | 
			
		||||
    get_content_element: (element) => element,
 | 
			
		||||
    get_scroll_element: (element) => element,
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/ui").with(ui);
 | 
			
		||||
mock_module("ui", ui);
 | 
			
		||||
set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const denmark_stream_id = 101;
 | 
			
		||||
@@ -20,7 +20,7 @@ set_global("location", {
 | 
			
		||||
    hash: `#streams/${denmark_stream_id}/announce`,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/hash_util").with({
 | 
			
		||||
mock_module("hash_util", {
 | 
			
		||||
    by_stream_uri: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
mock_module("resize", {
 | 
			
		||||
    resize_stream_filters_container: () => {},
 | 
			
		||||
});
 | 
			
		||||
const {Filter} = zrequire("../js/filter");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,19 +4,19 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const narrow_state = {
 | 
			
		||||
    topic() {},
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/narrow_state").with(narrow_state);
 | 
			
		||||
mock_module("narrow_state", narrow_state);
 | 
			
		||||
const muting = {
 | 
			
		||||
    is_topic_muted() {
 | 
			
		||||
        return false;
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/muting").with(muting);
 | 
			
		||||
mock_module("muting", muting);
 | 
			
		||||
const stream_data = zrequire("stream_data");
 | 
			
		||||
 | 
			
		||||
const unread = zrequire("unread");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,22 +2,22 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const reload = rewiremock("../../static/js/reload").with({});
 | 
			
		||||
const reload_state = rewiremock("../../static/js/reload_state").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const reload = mock_module("reload");
 | 
			
		||||
const reload_state = mock_module("reload_state");
 | 
			
		||||
 | 
			
		||||
const sent_messages = {
 | 
			
		||||
    start_tracking_message: noop,
 | 
			
		||||
    report_server_ack: noop,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/sent_messages").with(sent_messages);
 | 
			
		||||
mock_module("sent_messages", sent_messages);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const transmit = zrequire("transmit");
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
// become clear as you keep reading.
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, with_field, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {make_stub} = require("../zjsunit/stub");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
@@ -19,29 +19,29 @@ const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
const activity = rewiremock("../../static/js/activity").with({});
 | 
			
		||||
const activity = mock_module("activity");
 | 
			
		||||
const home_msg_list = set_global("home_msg_list", {});
 | 
			
		||||
const message_list = rewiremock("../../static/js/message_list").with({});
 | 
			
		||||
const message_live_update = rewiremock("../../static/js/message_live_update").with({});
 | 
			
		||||
const message_util = rewiremock("../../static/js/message_util").with({});
 | 
			
		||||
const notifications = rewiremock("../../static/js/notifications").with({});
 | 
			
		||||
const overlays = rewiremock("../../static/js/overlays").with({});
 | 
			
		||||
const pm_list = rewiremock("../../static/js/pm_list").with({});
 | 
			
		||||
const resize = rewiremock("../../static/js/resize").with({});
 | 
			
		||||
const settings_users = rewiremock("../../static/js/settings_users").with({});
 | 
			
		||||
const message_list = mock_module("message_list");
 | 
			
		||||
const message_live_update = mock_module("message_live_update");
 | 
			
		||||
const message_util = mock_module("message_util");
 | 
			
		||||
const notifications = mock_module("notifications");
 | 
			
		||||
const overlays = mock_module("overlays");
 | 
			
		||||
const pm_list = mock_module("pm_list");
 | 
			
		||||
const resize = mock_module("resize");
 | 
			
		||||
const settings_users = mock_module("settings_users");
 | 
			
		||||
 | 
			
		||||
let stream_list = {};
 | 
			
		||||
rewiremock("../../static/js/stream_list").with(stream_list);
 | 
			
		||||
mock_module("stream_list", stream_list);
 | 
			
		||||
let unread_ops = {};
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const message_viewport = rewiremock("../../static/js/message_viewport").with({});
 | 
			
		||||
const unread_ui = rewiremock("../../static/js/unread_ui").with({});
 | 
			
		||||
rewiremock("../../static/js/unread_ops").with(unread_ops);
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const message_viewport = mock_module("message_viewport");
 | 
			
		||||
const unread_ui = mock_module("unread_ui");
 | 
			
		||||
mock_module("unread_ops", unread_ops);
 | 
			
		||||
 | 
			
		||||
const topic_list = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/topic_list").with(topic_list);
 | 
			
		||||
mock_module("topic_list", topic_list);
 | 
			
		||||
// Let's start with testing a function from util.js.
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const _ = require("lodash");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
let page_params = set_global("page_params", {
 | 
			
		||||
@@ -15,7 +15,7 @@ set_global("current_msg_list", {});
 | 
			
		||||
set_global("home_msg_list", {});
 | 
			
		||||
const message_store = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_store").with(message_store);
 | 
			
		||||
mock_module("message_store", message_store);
 | 
			
		||||
const muting = zrequire("muting");
 | 
			
		||||
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,45 +2,45 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/activity").with({
 | 
			
		||||
mock_module("activity", {
 | 
			
		||||
    redraw() {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/settings_linkifiers").with({
 | 
			
		||||
mock_module("settings_linkifiers", {
 | 
			
		||||
    maybe_disable_widgets() {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/settings_org").with({
 | 
			
		||||
mock_module("settings_org", {
 | 
			
		||||
    maybe_disable_widgets() {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/settings_profile_fields").with({
 | 
			
		||||
mock_module("settings_profile_fields", {
 | 
			
		||||
    maybe_disable_widgets() {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/settings_streams").with({
 | 
			
		||||
mock_module("settings_streams", {
 | 
			
		||||
    maybe_disable_widgets() {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock("../../static/js/settings_users").with({
 | 
			
		||||
mock_module("settings_users", {
 | 
			
		||||
    update_user_data() {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/gear_menu").with({
 | 
			
		||||
mock_module("gear_menu", {
 | 
			
		||||
    update_org_settings_menu_item() {},
 | 
			
		||||
});
 | 
			
		||||
const page_params = set_global("page_params", {
 | 
			
		||||
    is_admin: true,
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/pm_list").with({
 | 
			
		||||
mock_module("pm_list", {
 | 
			
		||||
    update_private_messages() {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/narrow_state").with({
 | 
			
		||||
mock_module("narrow_state", {
 | 
			
		||||
    update_email() {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/compose").with({
 | 
			
		||||
mock_module("compose", {
 | 
			
		||||
    update_email() {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -49,10 +49,10 @@ const settings_account = {
 | 
			
		||||
    update_full_name() {},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/settings_account").with(settings_account);
 | 
			
		||||
mock_module("settings_account", settings_account);
 | 
			
		||||
const message_live_update = {};
 | 
			
		||||
 | 
			
		||||
rewiremock("../../static/js/message_live_update").with(message_live_update);
 | 
			
		||||
mock_module("message_live_update", message_live_update);
 | 
			
		||||
const people = zrequire("people");
 | 
			
		||||
 | 
			
		||||
const settings_config = zrequire("settings_config");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
const channel = rewiremock("../../static/js/channel").with({});
 | 
			
		||||
const channel = mock_module("channel");
 | 
			
		||||
const user_status = zrequire("user_status");
 | 
			
		||||
 | 
			
		||||
function initialize() {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {mock_module, set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
@@ -36,7 +36,7 @@ const events = [
 | 
			
		||||
let widget_elem;
 | 
			
		||||
let is_event_handled;
 | 
			
		||||
let is_widget_activated;
 | 
			
		||||
rewiremock("../../static/js/poll_widget").with({
 | 
			
		||||
mock_module("poll_widget", {
 | 
			
		||||
    activate(data) {
 | 
			
		||||
        is_widget_activated = true;
 | 
			
		||||
        widget_elem = data.elem;
 | 
			
		||||
@@ -52,7 +52,7 @@ rewiremock("../../static/js/poll_widget").with({
 | 
			
		||||
});
 | 
			
		||||
set_global("document", "document-stub");
 | 
			
		||||
 | 
			
		||||
const narrow_state = rewiremock("../../static/js/narrow_state").with({});
 | 
			
		||||
const narrow_state = mock_module("narrow_state");
 | 
			
		||||
set_global("current_msg_list", {});
 | 
			
		||||
 | 
			
		||||
const widgetize = zrequire("widgetize");
 | 
			
		||||
 
 | 
			
		||||
@@ -18,31 +18,42 @@ exports.start = () => {
 | 
			
		||||
    mock_names = new Set();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.rewiremock = (fn) => {
 | 
			
		||||
    if (!fn.startsWith("../../static/js/")) {
 | 
			
		||||
        throw new Error(`We only mock static/js files`);
 | 
			
		||||
exports.mock_module = (short_fn, obj) => {
 | 
			
		||||
    if (obj === undefined) {
 | 
			
		||||
        obj = {};
 | 
			
		||||
    }
 | 
			
		||||
    const short_fn = fn.slice("../../static/js/".length);
 | 
			
		||||
 | 
			
		||||
    if (typeof obj !== "object") {
 | 
			
		||||
        throw new TypeError("We expect you to stub with an object.");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (mock_names.has(short_fn)) {
 | 
			
		||||
        throw new Error(`You already set up a mock for ${short_fn}`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (short_fn.startsWith("/") || short_fn.includes(".")) {
 | 
			
		||||
        throw new Error(`
 | 
			
		||||
            There is no need for a path like ${short_fn}.
 | 
			
		||||
            We just assume the file is under static/js.
 | 
			
		||||
        `);
 | 
			
		||||
    }
 | 
			
		||||
    if (objs_installed) {
 | 
			
		||||
        throw new Error(`
 | 
			
		||||
            It is too late to install this mock.  Consider instead:
 | 
			
		||||
 | 
			
		||||
                foo.__Rewire__("${short_fn}", ...)
 | 
			
		||||
 | 
			
		||||
            Or call this earlier.
 | 
			
		||||
        `);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const base_path = path.resolve("./static/js");
 | 
			
		||||
    const long_fn = path.join(base_path, short_fn);
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
        with: (obj) => {
 | 
			
		||||
            if (objs_installed) {
 | 
			
		||||
                throw new Error(`
 | 
			
		||||
                    It is too late to install this mock.  Consider instead:
 | 
			
		||||
 | 
			
		||||
                        foo.__Rewire__(${short_fn}, ...)
 | 
			
		||||
 | 
			
		||||
                    Or call this earlier.
 | 
			
		||||
                `);
 | 
			
		||||
            }
 | 
			
		||||
            obj.__esModule = true;
 | 
			
		||||
            mock_paths[long_fn] = obj;
 | 
			
		||||
            mock_names.add(short_fn);
 | 
			
		||||
            return obj;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    obj.__esModule = true;
 | 
			
		||||
    mock_paths[long_fn] = obj;
 | 
			
		||||
    mock_names.add(short_fn);
 | 
			
		||||
    return obj;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.set_global = function (name, val) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user