zjsunit: Remove rewiremock dependency.

We now just use a module._load hook to inject
stubs into our code.

For conversion purposes I temporarily maintain
the API of rewiremock, apart from the enable/disable
pieces, but I will make a better wrapper in an
upcoming commit.

We can detect when rewiremock is called after
zrequire now, and I fix all the violations in
this commit, mostly by using override.

We can also detect when a mock is needlessly
created, and I fix all the violations in this
commit.

The one minor nuisance that this commit introduces
is that you can only stub out modules in the Zulip
source tree, which is now static/js.  This should
not really be a problem--there are usually better
techniques to deal with third party depenencies.
In the prior commit I show a typical workaround,
which is to create a one-line wrapper in your
test code.  It's often the case that you can simply
use override(), as well.

In passing I kill off `reset_modules`, and I
eliminated the second argument to zrequire,
which dates back to pre-es6 days.
This commit is contained in:
Steve Howell 2021-03-06 11:47:54 +00:00 committed by Steve Howell
parent 8006c29748
commit 30c7108955
93 changed files with 278 additions and 663 deletions

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -27,11 +25,6 @@ const _document = {
const channel = {__esModule: true}; const channel = {__esModule: true};
const _ui = {
__esModule: true,
get_content_element: (element) => element,
};
const _keydown_util = { const _keydown_util = {
__esModule: true, __esModule: true,
@ -82,13 +75,10 @@ rewiremock("../../static/js/popovers").with(_popovers);
rewiremock("../../static/js/resize").with(_resize); rewiremock("../../static/js/resize").with(_resize);
rewiremock("../../static/js/scroll_util").with(_scroll_util); rewiremock("../../static/js/scroll_util").with(_scroll_util);
rewiremock("../../static/js/stream_popover").with(_stream_popover); rewiremock("../../static/js/stream_popover").with(_stream_popover);
rewiremock("../../static/js/ui").with(_ui);
rewiremock("../../static/js/server_events").with({ rewiremock("../../static/js/server_events").with({
check_for_unsuspend() {}, check_for_unsuspend() {},
}); });
rewiremock.enable();
const huddle_data = zrequire("huddle_data"); const huddle_data = zrequire("huddle_data");
const compose_fade = zrequire("compose_fade"); const compose_fade = zrequire("compose_fade");
const narrow = zrequire("narrow"); const narrow = zrequire("narrow");
@ -760,4 +750,3 @@ test_ui("test_send_or_receive_no_presence_for_web_public_visitor", () => {
page_params.is_web_public_visitor = true; page_params.is_web_public_visitor = true;
activity.send_presence_to_server(); activity.send_presence_to_server();
}); });
rewiremock.disable();

View File

@ -2,17 +2,14 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {zrequire} = require("../zjsunit/namespace"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
const channel = {__esModule: true}; const channel = {__esModule: true};
rewiremock("../../static/js/channel").with(channel); rewiremock("../../static/js/channel").with(channel);
rewiremock.enable();
const alert_words = zrequire("alert_words"); const alert_words = zrequire("alert_words");
const alert_words_ui = zrequire("alert_words_ui"); const alert_words_ui = zrequire("alert_words_ui");
@ -197,4 +194,3 @@ run_test("close_status_message", (override) => {
close(event); close(event);
assert(!alert.visible()); assert(!alert.visible());
}); });
rewiremock.disable();

View File

@ -4,9 +4,8 @@ const {strict: assert} = require("assert");
const fs = require("fs"); const fs = require("fs");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const rewiremock = require("rewiremock/node");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -23,8 +22,6 @@ const StripeCheckout = set_global("StripeCheckout", {
configure: () => {}, configure: () => {},
}); });
rewiremock.enable();
run_test("initialize", (override) => { run_test("initialize", (override) => {
let token_func; let token_func;
@ -72,7 +69,7 @@ run_test("initialize", (override) => {
$("#payment-method").data = (key) => $("#payment-method").data = (key) =>
document.querySelector("#payment-method").getAttribute("data-" + key); document.querySelector("#payment-method").getAttribute("data-" + key);
zrequire("billing", "js/billing/billing"); zrequire("billing/billing");
assert(set_tab_called); assert(set_tab_called);
assert(stripe_checkout_configure_called); assert(stripe_checkout_configure_called);
@ -112,4 +109,3 @@ run_test("billing_template", () => {
assert(document.querySelector("input[name=csrfmiddlewaretoken]")); assert(document.querySelector("input[name=csrfmiddlewaretoken]"));
}); });
rewiremock.disable();

View File

@ -5,9 +5,8 @@ const fs = require("fs");
const jQueryFactory = require("jquery"); const jQueryFactory = require("jquery");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -28,9 +27,7 @@ set_global("location", {
hash: "#billing", hash: "#billing",
}); });
rewiremock.enable(); const helpers = zrequire("billing/helpers");
const helpers = zrequire("helpers", "js/billing/helpers");
run_test("create_ajax_request", (override) => { run_test("create_ajax_request", (override) => {
const form_loading_indicator = "#autopay_loading_indicator"; const form_loading_indicator = "#autopay_loading_indicator";
@ -290,4 +287,3 @@ run_test("set_tab", () => {
assert.equal(state.show_tab_payment_method, 1); assert.equal(state.show_tab_payment_method, 1);
assert.equal(state.scrollTop, 2); assert.equal(state.scrollTop, 2);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const _settings_bots = { const _settings_bots = {
@ -14,8 +12,6 @@ const _settings_bots = {
rewiremock("../../static/js/settings_bots").with(_settings_bots); rewiremock("../../static/js/settings_bots").with(_settings_bots);
rewiremock.enable();
const bot_data = zrequire("bot_data"); const bot_data = zrequire("bot_data");
const people = zrequire("people"); const people = zrequire("people");
@ -176,4 +172,3 @@ run_test("test_basics", () => {
assert.equal(bots[1].email, "bot2@zulip.com"); assert.equal(bots[1].email, "bot2@zulip.com");
})(); })();
}); });
rewiremock.disable();

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const page_params = set_global("page_params", {}); const page_params = set_global("page_params", {});
@ -13,7 +12,6 @@ const page_params = set_global("page_params", {});
const timerender = {__esModule: true}; const timerender = {__esModule: true};
rewiremock("../../static/js/timerender").with(timerender); rewiremock("../../static/js/timerender").with(timerender);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const presence = zrequire("presence"); const presence = zrequire("presence");
@ -355,4 +353,3 @@ run_test("error handling", (override) => {
blueslip.expect("warn", "Got user_id in presence but not people: 42"); blueslip.expect("warn", "Got user_id in presence but not people: 42");
buddy_data.get_filtered_and_sorted_user_ids(); buddy_data.get_filtered_and_sorted_user_ids();
}); });
rewiremock.disable();

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {zrequire} = require("../zjsunit/namespace"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -17,8 +16,6 @@ rewiremock("../../static/js/message_viewport").with({
height: () => 550, height: () => 550,
}); });
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const {buddy_list} = zrequire("buddy_list"); const {buddy_list} = zrequire("buddy_list");
@ -226,4 +223,3 @@ run_test("scrolling", (override) => {
assert(tried_to_fill); assert(tried_to_fill);
}); });
rewiremock.disable();

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const reload = {__esModule: true}; const reload = {__esModule: true};
@ -17,8 +16,6 @@ set_global("setTimeout", (f, delay) => {
f(); f();
}); });
rewiremock.enable();
const channel = zrequire("channel"); const channel = zrequire("channel");
const default_stub_xhr = "default-stub-xhr"; const default_stub_xhr = "default-stub-xhr";
@ -315,4 +312,3 @@ run_test("xhr_error_message", () => {
msg = "some message"; msg = "some message";
assert.equal(channel.xhr_error_message(msg, xhr), "some message: file not found"); assert.equal(channel.xhr_error_message(msg, xhr), "some message: file not found");
}); });
rewiremock.disable();

View File

@ -4,10 +4,9 @@ const {strict: assert} = require("assert");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const MockDate = require("mockdate"); const MockDate = require("mockdate");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -27,6 +26,8 @@ rewiremock("../../static/js/compose_actions").with({
}, },
}); });
const server_events = rewiremock("../../static/js/server_events").with({__esModule: true});
const _navigator = { const _navigator = {
platform: "", platform: "",
}; };
@ -97,8 +98,7 @@ document.location.host = "foo.com";
const fake_now = 555; const fake_now = 555;
MockDate.set(new Date(fake_now * 1000)); MockDate.set(new Date(fake_now * 1000));
rewiremock.enable(); const compose_fade = zrequire("compose_fade");
const peer_data = zrequire("peer_data"); const peer_data = zrequire("peer_data");
const util = zrequire("util"); const util = zrequire("util");
const rtl = zrequire("rtl"); const rtl = zrequire("rtl");
@ -716,7 +716,7 @@ test_ui("send_message_success", () => {
assert(reify_message_id_checked); assert(reify_message_id_checked);
}); });
test_ui("send_message", () => { test_ui("send_message", (override) => {
// This is the common setup stuff for all of the four tests. // This is the common setup stuff for all of the four tests.
let stub_state; let stub_state;
function initialize_state_stub_dict() { function initialize_state_stub_dict() {
@ -730,10 +730,9 @@ test_ui("send_message", () => {
set_global("setTimeout", (func) => { set_global("setTimeout", (func) => {
func(); func();
}); });
rewiremock("../../static/js/server_events").with({
assert_get_events_running() { override(server_events, "assert_get_events_running", () => {
stub_state.get_events_running_called += 1; stub_state.get_events_running_called += 1;
},
}); });
// Tests start here. // Tests start here.
@ -1105,7 +1104,7 @@ test_ui("initialize", (override) => {
})(); })();
}); });
test_ui("update_fade", () => { test_ui("update_fade", (override) => {
const selector = const selector =
"#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient"; "#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient";
const keyup_handler_func = $(selector).get_on_handler("keyup"); const keyup_handler_func = $(selector).get_on_handler("keyup");
@ -1113,14 +1112,13 @@ test_ui("update_fade", () => {
let set_focused_recipient_checked = false; let set_focused_recipient_checked = false;
let update_all_called = false; let update_all_called = false;
rewiremock("../../static/js/compose_fade").with({ override(compose_fade, "set_focused_recipient", (msg_type) => {
set_focused_recipient(msg_type) { assert.equal(msg_type, "private");
assert.equal(msg_type, "private"); set_focused_recipient_checked = true;
set_focused_recipient_checked = true; });
},
update_all() { override(compose_fade, "update_all", () => {
update_all_called = true; update_all_called = true;
},
}); });
compose_state.set_message_type(false); compose_state.set_message_type(false);
@ -1729,5 +1727,3 @@ test_ui("narrow_button_titles", () => {
}); });
MockDate.reset(); MockDate.reset();
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -69,8 +67,6 @@ const channel = {__esModule: true};
rewiremock("../../static/js/channel").with(channel); rewiremock("../../static/js/channel").with(channel);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const compose_ui = zrequire("compose_ui"); const compose_ui = zrequire("compose_ui");
const compose = zrequire("compose"); const compose = zrequire("compose");
@ -502,4 +498,3 @@ run_test("on_narrow", (override) => {
}); });
assert(cancel_called); assert(cancel_called);
}); });
rewiremock.disable();

View File

@ -2,21 +2,16 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
rewiremock.enable(); const compose_actions = {__esModule: true};
rewiremock("../../static/js/compose_actions").with(compose_actions);
const people = zrequire("people"); const people = zrequire("people");
const compose_pm_pill = zrequire("compose_pm_pill"); const compose_pm_pill = zrequire("compose_pm_pill");
const input_pill = zrequire("input_pill"); const input_pill = zrequire("input_pill");
const compose_actions = {__esModule: true};
rewiremock("../../static/js/compose_actions").with(compose_actions);
let pills = { let pills = {
pill: {}, pill: {},
@ -199,4 +194,3 @@ run_test("has_unconverted_data", () => {
// we have some unconverted data. // we have some unconverted data.
assert.equal(compose_pm_pill.has_unconverted_data(), true); assert.equal(compose_pm_pill.has_unconverted_data(), true);
}); });
rewiremock.disable();

View File

@ -2,12 +2,9 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
rewiremock.enable();
const compose_pm_pill = {__esModule: true}; const compose_pm_pill = {__esModule: true};
rewiremock("../../static/js/compose_pm_pill").with(compose_pm_pill); rewiremock("../../static/js/compose_pm_pill").with(compose_pm_pill);
@ -25,4 +22,3 @@ run_test("private_message_recipient", (override) => {
compose_state.private_message_recipient("fred@fred.org"); compose_state.private_message_recipient("fred@fred.org");
assert.equal(compose_state.private_message_recipient(), "fred@fred.org"); assert.equal(compose_state.private_message_recipient(), "fred@fred.org");
}); });
rewiremock.disable();

View File

@ -2,16 +2,12 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
const events = require("./lib/events"); const events = require("./lib/events");
rewiremock.enable();
const resize = { const resize = {
__esModule: true, __esModule: true,
watch_manual_resize() {}, watch_manual_resize() {},
@ -253,4 +249,3 @@ run_test("test_video_chat_button_toggle enabled", (override) => {
compose.initialize(); compose.initialize();
assert.equal($("#below-compose-content .video_link").visible(), true); assert.equal($("#below-compose-content .video_link").visible(), true);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -45,10 +43,8 @@ set_global("setTimeout", (f, time) => {
}); });
set_global("document", "document-stub"); set_global("document", "document-stub");
rewiremock.enable(); const emoji = zrequire("../shared/js/emoji");
const typeahead = zrequire("../shared/js/typeahead");
const emoji = zrequire("emoji", "shared/js/emoji");
const typeahead = zrequire("typeahead", "shared/js/typeahead");
const compose_state = zrequire("compose_state"); const compose_state = zrequire("compose_state");
zrequire("user_status"); zrequire("user_status");
zrequire("presence"); zrequire("presence");
@ -63,7 +59,7 @@ const user_pill = zrequire("user_pill");
const compose_pm_pill = zrequire("compose_pm_pill"); const compose_pm_pill = zrequire("compose_pm_pill");
const composebox_typeahead = zrequire("composebox_typeahead"); const composebox_typeahead = zrequire("composebox_typeahead");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); const pygments_data = zrequire("../generated/pygments_data.json");
// To be eliminated in next commit: // To be eliminated in next commit:
stream_data.__Rewire__("update_calculated_fields", () => {}); stream_data.__Rewire__("update_calculated_fields", () => {});
@ -1567,4 +1563,3 @@ run_test("message people", () => {
// harry is excluded since it has been deactivated. // harry is excluded since it has been deactivated.
assert.deepEqual(results, [hamletcharacters, hal]); assert.deepEqual(results, [hamletcharacters, hal]);
}); });
rewiremock.disable();

View File

@ -4,9 +4,8 @@ const {strict: assert} = require("assert");
const jquery = require("jquery"); const jquery = require("jquery");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
set_global("page_params", { set_global("page_params", {
@ -23,8 +22,6 @@ const $ = set_global("$", jquery(window));
set_global("DOMParser", DOMParser); set_global("DOMParser", DOMParser);
set_global("document", document); set_global("document", document);
rewiremock.enable();
const copy_and_paste = zrequire("copy_and_paste"); const copy_and_paste = zrequire("copy_and_paste");
// Super stripped down version of the code in the drag-mock library // Super stripped down version of the code in the drag-mock library
@ -116,4 +113,3 @@ run_test("paste_handler", () => {
copy_and_paste.paste_handler(event); copy_and_paste.paste_handler(event);
assert(!insert_syntax_and_focus_called); assert(!insert_syntax_and_focus_called);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -112,8 +110,6 @@ const page_params = set_global("page_params", {
realm_description: "already set description", realm_description: "already set description",
}); });
rewiremock.enable();
// For data-oriented modules, just use them, don't stub them. // For data-oriented modules, just use them, don't stub them.
const alert_words = zrequire("alert_words"); const alert_words = zrequire("alert_words");
const stream_topic_history = zrequire("stream_topic_history"); const stream_topic_history = zrequire("stream_topic_history");
@ -123,7 +119,7 @@ const people = zrequire("people");
const starred_messages = zrequire("starred_messages"); const starred_messages = zrequire("starred_messages");
const user_status = zrequire("user_status"); const user_status = zrequire("user_status");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("../shared/js/emoji");
const server_events_dispatch = zrequire("server_events_dispatch"); const server_events_dispatch = zrequire("server_events_dispatch");
@ -137,7 +133,7 @@ people.add_active_user(test_user);
message_store.add_message_metadata(test_message); message_store.add_message_metadata(test_message);
const realm_emoji = {}; const realm_emoji = {};
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
emoji.initialize({realm_emoji, emoji_codes}); emoji.initialize({realm_emoji, emoji_codes});
@ -893,4 +889,3 @@ run_test("realm_export", (override) => {
const args = stub.get_args("exports"); const args = stub.get_args("exports");
assert.equal(args.exports, event.exports); assert.equal(args.exports, event.exports);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
@ -21,12 +19,6 @@ const subs = {__esModule: true};
rewiremock("../../static/js/subs").with(subs); rewiremock("../../static/js/subs").with(subs);
rewiremock.enable();
const peer_data = zrequire("peer_data");
const people = zrequire("people");
const stream_data = zrequire("stream_data");
set_global("current_msg_list", {}); set_global("current_msg_list", {});
const narrow_state = {__esModule: true}; const narrow_state = {__esModule: true};
rewiremock("../../static/js/narrow_state").with(narrow_state); rewiremock("../../static/js/narrow_state").with(narrow_state);
@ -41,6 +33,10 @@ const stream_list = {__esModule: true};
rewiremock("../../static/js/stream_list").with(stream_list); rewiremock("../../static/js/stream_list").with(stream_list);
const peer_data = zrequire("peer_data");
const people = zrequire("people");
const stream_data = zrequire("stream_data");
const server_events_dispatch = zrequire("server_events_dispatch"); const server_events_dispatch = zrequire("server_events_dispatch");
const noop = () => {}; const noop = () => {};
@ -280,4 +276,3 @@ test("stream delete (special streams)", (override) => {
assert.equal(page_params.realm_notifications_stream_id, -1); assert.equal(page_params.realm_notifications_stream_id, -1);
assert.equal(page_params.realm_signup_notifications_stream_id, -1); assert.equal(page_params.realm_signup_notifications_stream_id, -1);
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire, with_overrides} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire, with_overrides} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -40,8 +38,6 @@ set_global("page_params", {
twenty_four_hour_time: false, twenty_four_hour_time: false,
}); });
rewiremock.enable();
const {localstorage} = zrequire("localstorage"); const {localstorage} = zrequire("localstorage");
const drafts = zrequire("drafts"); const drafts = zrequire("drafts");
const timerender = zrequire("timerender"); const timerender = zrequire("timerender");
@ -304,4 +300,3 @@ run_test("format_drafts", (override) => {
drafts.launch(); drafts.launch();
timerender.__Rewire__("render_now", stub_render_now); timerender.__Rewire__("render_now", stub_render_now);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -15,8 +13,6 @@ const _ListWidget = {
}; };
rewiremock("../../static/js/list_widget").with(_ListWidget); rewiremock("../../static/js/list_widget").with(_ListWidget);
rewiremock.enable();
const {DropdownListWidget: dropdown_list_widget} = zrequire("dropdown_list_widget"); const {DropdownListWidget: dropdown_list_widget} = zrequire("dropdown_list_widget");
const setup_zjquery_data = (name) => { const setup_zjquery_data = (name) => {
@ -79,4 +75,3 @@ run_test("no_default_value", () => {
const widget = dropdown_list_widget(opts); const widget = dropdown_list_widget(opts);
assert.equal(widget.value(), "null-value"); assert.equal(widget.value(), "null-value");
}); });
rewiremock.disable();

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const MockDate = require("mockdate"); const MockDate = require("mockdate");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const local_message = {__esModule: true}; const local_message = {__esModule: true};
@ -47,8 +46,6 @@ rewiremock("../../static/js/message_list").with({});
set_global("current_msg_list", ""); set_global("current_msg_list", "");
rewiremock.enable();
const echo = zrequire("echo"); const echo = zrequire("echo");
const people = zrequire("people"); const people = zrequire("people");
@ -264,4 +261,3 @@ run_test("insert_local_message PM", (override) => {
}); });
MockDate.reset(); MockDate.reset();
rewiremock.disable();

View File

@ -5,11 +5,11 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace"); const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
const events = require("./lib/events"); const events = require("./lib/events");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("../shared/js/emoji");
const realm_emoji = events.test_realm_emojis; const realm_emoji = events.test_realm_emojis;

View File

@ -7,10 +7,10 @@ const _ = require("lodash");
const {zrequire} = require("../zjsunit/namespace"); const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("../shared/js/emoji");
const emoji_picker = zrequire("emoji_picker"); const emoji_picker = zrequire("emoji_picker");
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
run_test("initialize", () => { run_test("initialize", () => {
emoji.initialize({ emoji.initialize({

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace"); const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const fenced_code = zrequire("fenced_code", "shared/js/fenced_code"); const fenced_code = zrequire("../shared/js/fenced_code");
run_test("get_unused_fence", () => { run_test("get_unused_fence", () => {
assert.equal(fenced_code.get_unused_fence("```js\nsomething\n```"), "`".repeat(4)); assert.equal(fenced_code.get_unused_fence("```js\nsomething\n```"), "`".repeat(4));

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
rewiremock("../../static/js/message_scroll").with({ rewiremock("../../static/js/message_scroll").with({
@ -14,8 +12,6 @@ rewiremock("../../static/js/message_scroll").with({
show_loading_newer: () => {}, show_loading_newer: () => {},
}); });
rewiremock.enable();
const {FetchStatus} = zrequire("fetch_status"); const {FetchStatus} = zrequire("fetch_status");
let fetch_status = new FetchStatus(); let fetch_status = new FetchStatus();
@ -180,4 +176,3 @@ run_test("basics", () => {
can_load_older(); can_load_older();
blocked_newer(); blocked_newer();
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -12,11 +10,9 @@ const message_store = {__esModule: true};
rewiremock("../../static/js/message_store").with(message_store); rewiremock("../../static/js/message_store").with(message_store);
const page_params = set_global("page_params", {}); const page_params = set_global("page_params", {});
rewiremock.enable();
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const people = zrequire("people"); const people = zrequire("people");
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
const me = { const me = {
email: "me@example.com", email: "me@example.com",
@ -1556,4 +1552,3 @@ run_test("error_cases", () => {
const predicate = get_predicate([["pm-with", "Joe@example.com"]]); const predicate = get_predicate([["pm-with", "Joe@example.com"]]);
assert(!predicate({type: "private"})); assert(!predicate({type: "private"}));
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const ui_report = { const ui_report = {
@ -22,12 +20,10 @@ set_global("location", {
pathname: "/", pathname: "/",
}); });
rewiremock.enable();
const hash_util = zrequire("hash_util"); const hash_util = zrequire("hash_util");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const people = zrequire("people"); const people = zrequire("people");
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
const narrow_state = zrequire("narrow_state"); const narrow_state = zrequire("narrow_state");
const hamlet = { const hamlet = {
@ -179,4 +175,3 @@ run_test("test_search_public_streams_notice_url", () => {
"#narrow/streams/public/sender/15-hamlet", "#narrow/streams/public/sender/15-hamlet",
); );
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -46,8 +44,6 @@ rewiremock("../../static/js/top_left_corner").with({
handle_narrow_deactivated: () => {}, handle_narrow_deactivated: () => {},
}); });
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const hash_util = zrequire("hash_util"); const hash_util = zrequire("hash_util");
const hashchange = zrequire("hashchange"); const hashchange = zrequire("hashchange");
@ -317,4 +313,3 @@ run_test("save_narrow", () => {
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]); helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
assert.equal(url_pushed, "http://example.com/#narrow/is/starred"); assert.equal(url_pushed, "http://example.com/#narrow/is/starred");
}); });
rewiremock.disable();

View File

@ -2,9 +2,13 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {
rewiremock,
const {set_global, with_field, with_overrides, zrequire} = require("../zjsunit/namespace"); set_global,
with_field,
with_overrides,
zrequire,
} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
@ -130,10 +134,8 @@ rewiremock("../../static/js/recent_topics").with({
is_visible: () => false, is_visible: () => false,
}); });
rewiremock.enable(); const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
const emoji = zrequire("../shared/js/emoji");
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
const emoji = zrequire("emoji", "shared/js/emoji");
const activity = zrequire("activity"); const activity = zrequire("activity");
const hotkey = zrequire("hotkey"); const hotkey = zrequire("hotkey");
@ -522,4 +524,3 @@ run_test("motion_keys", () => {
overlays.is_active = () => false; overlays.is_active = () => false;
overlays.drafts_open = () => false; overlays.drafts_open = () => false;
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -21,8 +19,6 @@ set_global("getSelection", () => ({
anchorOffset: 0, anchorOffset: 0,
})); }));
rewiremock.enable();
zrequire("templates"); zrequire("templates");
const input_pill = zrequire("input_pill"); const input_pill = zrequire("input_pill");
@ -604,4 +600,3 @@ run_test("appendValue/clear", () => {
assert.deepEqual(removed_colors, ["blue", "yellow", "red"]); assert.deepEqual(removed_colors, ["blue", "yellow", "red"]);
assert.equal(pill_input[0].textContent, ""); assert.equal(pill_input[0].textContent, "");
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -18,13 +16,11 @@ rewiremock("../../static/js/popovers").with({
hide_all: () => {}, hide_all: () => {},
}); });
rewiremock.enable(); const message_store = {__esModule: true};
rewiremock("../../static/js/message_store").with(message_store);
const rows = zrequire("rows"); const rows = zrequire("rows");
const lightbox = zrequire("lightbox"); const lightbox = zrequire("lightbox");
const message_store = {__esModule: true};
rewiremock("../../static/js/message_store").with(message_store);
rows.__Rewire__("is_draft_row", () => false); rows.__Rewire__("is_draft_row", () => false);
@ -90,4 +86,3 @@ run_test("youtube", (override) => {
lightbox.open(img); lightbox.open(img);
assert.equal($(".image-actions .open").attr("href"), href); assert.equal($(".image-actions .open").attr("href"), href);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
// We need these stubs to get by instanceof checks. // We need these stubs to get by instanceof checks.
@ -36,8 +34,6 @@ set_global("$", (arg) => {
}; };
}); });
rewiremock.enable();
const ListWidget = zrequire("list_widget"); const ListWidget = zrequire("list_widget");
// We build objects here that simulate jQuery containers. // We build objects here that simulate jQuery containers.
@ -780,4 +776,3 @@ run_test("render item", () => {
widget_3.render_item(item); widget_3.render_item(item);
blueslip.reset(); blueslip.reset();
}); });
rewiremock.disable();

View File

@ -32,12 +32,12 @@ set_global("Image", Image);
const doc = ""; const doc = "";
set_global("document", doc); set_global("document", doc);
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("../shared/js/emoji");
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); const pygments_data = zrequire("../generated/pygments_data.json");
const fenced_code = zrequire("fenced_code", "shared/js/fenced_code"); const fenced_code = zrequire("../shared/js/fenced_code");
const markdown_config = zrequire("markdown_config"); const markdown_config = zrequire("markdown_config");
const marked = zrequire("marked", "third/marked/lib/marked"); const marked = zrequire("../third/marked/lib/marked");
const markdown = zrequire("markdown"); const markdown = zrequire("markdown");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");

View File

@ -7,19 +7,10 @@
There may be a better way. There may be a better way.
*/ */
const rewiremock = require("rewiremock/node"); const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
set_global("page_params", {}); set_global("page_params", {});
rewiremock("katex").with({
renderToString: () => {
throw new Error("some-exception");
},
});
rewiremock.enable();
const markdown_config = zrequire("markdown_config"); const markdown_config = zrequire("markdown_config");
@ -30,7 +21,16 @@ markdown.initialize([], markdown_config.get_helpers());
run_test("katex_throws_unexpected_exceptions", () => { run_test("katex_throws_unexpected_exceptions", () => {
blueslip.expect("error", "Error: some-exception"); blueslip.expect("error", "Error: some-exception");
const message = {raw_content: "$$a$$"}; const message = {raw_content: "$$a$$"};
markdown.apply_markdown(message); with_field(
markdown,
"katex",
{
renderToString: () => {
throw new Error("some-exception");
},
},
() => {
markdown.apply_markdown(message);
},
);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const condense = {__esModule: true}; const condense = {__esModule: true};
@ -24,7 +22,6 @@ rewiremock("../../static/js/stream_list").with(stream_list);
const unread_ui = {__esModule: true}; const unread_ui = {__esModule: true};
rewiremock("../../static/js/unread_ui").with(unread_ui); rewiremock("../../static/js/unread_ui").with(unread_ui);
rewiremock.enable();
const message_events = zrequire("message_events"); const message_events = zrequire("message_events");
const message_store = zrequire("message_store"); const message_store = zrequire("message_store");
@ -160,4 +157,3 @@ run_test("update_messages", () => {
}, },
]); ]);
}); });
rewiremock.disable();

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -54,10 +53,8 @@ const stream_list = {
rewiremock("../../static/js/stream_list").with(stream_list); rewiremock("../../static/js/stream_list").with(stream_list);
rewiremock.enable();
const message_fetch = zrequire("message_fetch"); const message_fetch = zrequire("message_fetch");
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
const message_list = zrequire("message_list"); const message_list = zrequire("message_list");
const people = zrequire("people"); const people = zrequire("people");
@ -482,4 +479,3 @@ run_test("loading_newer", () => {
assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false); assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false);
})(); })();
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
rewiremock("../../static/js/starred_messages").with({ rewiremock("../../static/js/starred_messages").with({
@ -12,16 +10,14 @@ rewiremock("../../static/js/starred_messages").with({
remove: () => {}, remove: () => {},
}); });
rewiremock.enable();
const message_flags = zrequire("message_flags");
const ui = {__esModule: true}; const ui = {__esModule: true};
rewiremock("../../static/js/ui").with(ui); rewiremock("../../static/js/ui").with(ui);
const channel = {__esModule: true}; const channel = {__esModule: true};
rewiremock("../../static/js/channel").with(channel); rewiremock("../../static/js/channel").with(channel);
const message_flags = zrequire("message_flags");
run_test("starred", () => { run_test("starred", () => {
const message = { const message = {
id: 50, id: 50,
@ -171,4 +167,3 @@ run_test("read", () => {
success: channel_post_opts.success, success: channel_post_opts.success,
}); });
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -31,8 +29,6 @@ rewiremock("../../static/js/narrow_state").with(narrow_state);
const stream_data = {__esModule: true}; const stream_data = {__esModule: true};
rewiremock("../../static/js/stream_data").with(stream_data); rewiremock("../../static/js/stream_data").with(stream_data);
rewiremock.enable();
const muting = zrequire("muting"); const muting = zrequire("muting");
const {MessageList} = zrequire("message_list"); const {MessageList} = zrequire("message_list");
@ -444,4 +440,3 @@ run_test("add_remove_rerender", () => {
assert.equal(list.num_items(), 0); assert.equal(list.num_items(), 0);
} }
}); });
rewiremock.disable();

View File

@ -13,7 +13,7 @@ set_global("setTimeout", (f, delay) => {
}); });
const muting = zrequire("muting"); const muting = zrequire("muting");
const {MessageListData} = zrequire("MessageListData", "js/message_list_data"); const {MessageListData} = zrequire("../js/message_list_data");
function make_msg(msg_id) { function make_msg(msg_id) {
return { return {

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
set_global("document", "document-stub"); set_global("document", "document-stub");
@ -16,7 +15,6 @@ const page_params = set_global("page_params", {
twenty_four_hour_time: false, twenty_four_hour_time: false,
}); });
set_global("home_msg_list", "stub"); set_global("home_msg_list", "stub");
rewiremock("../../static/js/unread").with({message_unread() {}});
// timerender calls setInterval when imported // timerender calls setInterval when imported
rewiremock("../../static/js/timerender").with({ rewiremock("../../static/js/timerender").with({
render_date(time1, time2) { render_date(time1, time2) {
@ -45,10 +43,8 @@ rewiremock("../../static/js/rows").with({
}, },
}); });
rewiremock.enable(); const {Filter} = zrequire("../js/filter");
const {MessageListView} = zrequire("../js/message_list_view");
const {Filter} = zrequire("Filter", "js/filter");
const {MessageListView} = zrequire("MessageListView", "js/message_list_view");
const message_list = zrequire("message_list"); const message_list = zrequire("message_list");
let next_timestamp = 1500000000; let next_timestamp = 1500000000;
@ -545,4 +541,3 @@ run_test("render_windows", () => {
verify_move(197, [0, 400]); verify_move(197, [0, 400]);
verify_no_move_range(0, 350); verify_no_move_range(0, 350);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
@ -25,8 +23,6 @@ set_global("page_params", {
is_admin: true, is_admin: true,
}); });
rewiremock.enable();
const util = zrequire("util"); const util = zrequire("util");
const people = zrequire("people"); const people = zrequire("people");
const pm_conversations = zrequire("pm_conversations"); const pm_conversations = zrequire("pm_conversations");
@ -343,7 +339,6 @@ run_test("message_id_change", () => {
}, },
}); });
rewiremock("../../static/js/message_list").with({});
set_global("home_msg_list", {}); set_global("home_msg_list", {});
const opts = { const opts = {
@ -377,4 +372,3 @@ run_test("errors", () => {
blueslip.expect("error", "message_store.get got bad value: undefined"); blueslip.expect("error", "message_store.get got bad value: undefined");
message_store.get(undefined); message_store.get(undefined);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -12,16 +10,15 @@ set_global("page_params", {
stop_words: ["what", "about"], stop_words: ["what", "about"],
}); });
rewiremock.enable(); const stream_topic_history = {__esModule: true};
rewiremock("../../static/js/stream_topic_history").with(stream_topic_history);
const hash_util = zrequire("hash_util"); const hash_util = zrequire("hash_util");
const compose_state = zrequire("compose_state"); const compose_state = zrequire("compose_state");
const narrow_state = zrequire("narrow_state"); const narrow_state = zrequire("narrow_state");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_topic_history = {__esModule: true}; const {Filter} = zrequire("../js/filter");
rewiremock("../../static/js/stream_topic_history").with(stream_topic_history);
const {Filter} = zrequire("Filter", "js/filter");
const narrow = zrequire("narrow"); const narrow = zrequire("narrow");
function set_filter(operators) { function set_filter(operators) {
@ -372,4 +369,3 @@ run_test("narrow_to_compose_target PMs", (override) => {
assert.equal(args.called, true); assert.equal(args.called, true);
assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]); assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
rewiremock("../../static/js/resize").with({ rewiremock("../../static/js/resize").with({
@ -67,8 +65,6 @@ rewiremock("../../static/js/muting").with({
is_topic_muted: () => false, is_topic_muted: () => false,
}); });
rewiremock.enable();
const util = zrequire("util"); const util = zrequire("util");
const narrow_state = zrequire("narrow_state"); const narrow_state = zrequire("narrow_state");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
@ -245,4 +241,3 @@ run_test("basics", () => {
cont(); cont();
helper.assert_events(["report narrow times"]); helper.assert_events(["report narrow times"]);
}); });
rewiremock.disable();

View File

@ -2,18 +2,15 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const message_list = {__esModule: true}; const message_list = {__esModule: true};
rewiremock("../../static/js/message_list").with(message_list); rewiremock("../../static/js/message_list").with(message_list);
rewiremock.enable();
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
const {MessageListData} = zrequire("MessageListData", "js/message_list_data"); const {MessageListData} = zrequire("../js/message_list_data");
const narrow_state = zrequire("narrow_state"); const narrow_state = zrequire("narrow_state");
const narrow = zrequire("narrow"); const narrow = zrequire("narrow");
@ -450,4 +447,3 @@ run_test("final corner case", () => {
test_with(fixture); test_with(fixture);
}); });
rewiremock.disable();

View File

@ -8,7 +8,7 @@ const {run_test} = require("../zjsunit/test");
set_global("page_params", {}); set_global("page_params", {});
const people = zrequire("people"); const people = zrequire("people");
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const narrow_state = zrequire("narrow_state"); const narrow_state = zrequire("narrow_state");

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const message_store = {__esModule: true}; const message_store = {__esModule: true};
@ -15,9 +13,7 @@ rewiremock("../../static/js/muting").with({
is_topic_muted: () => false, is_topic_muted: () => false,
}); });
rewiremock.enable(); const {Filter} = zrequire("../js/filter");
const {Filter} = zrequire("Filter", "js/filter");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const unread = zrequire("unread"); const unread = zrequire("unread");
@ -212,4 +208,3 @@ run_test("defensive code", () => {
flavor: "cannot_compute", flavor: "cannot_compute",
}); });
}); });
rewiremock.disable();

View File

@ -5,7 +5,8 @@ const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn")); set_global("zxcvbn", require("zxcvbn"));
const common = zrequire("common"); const common = zrequire("common");
run_test("basics", () => { run_test("basics", () => {

View File

@ -5,17 +5,14 @@ const {strict: assert} = require("assert");
const {parseISO} = require("date-fns"); const {parseISO} = require("date-fns");
const _ = require("lodash"); const _ = require("lodash");
const MockDate = require("mockdate"); const MockDate = require("mockdate");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const message_store = {__esModule: true}; const message_store = {__esModule: true};
rewiremock("../../static/js/message_store").with(message_store); rewiremock("../../static/js/message_store").with(message_store);
const page_params = set_global("page_params", {}); const page_params = set_global("page_params", {});
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const visibility = settings_config.email_address_visibility_values; const visibility = settings_config.email_address_visibility_values;
@ -1117,4 +1114,3 @@ run_test("get_active_message_people", () => {
// reset to native Date() // reset to native Date()
MockDate.reset(); MockDate.reset();
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const reload_state = { const reload_state = {
@ -13,7 +11,6 @@ const reload_state = {
}; };
rewiremock("../../static/js/reload_state").with(reload_state); rewiremock("../../static/js/reload_state").with(reload_state);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
@ -121,4 +118,3 @@ run_test("blueslip", () => {
blueslip.expect("error", "Trying to set undefined field id"); blueslip.expect("error", "Trying to set undefined field id");
people.set_custom_profile_field_data(maria.user_id, {}); people.set_custom_profile_field_data(maria.user_id, {});
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, with_field, zrequire} = require("../zjsunit/namespace");
const {with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -29,8 +27,6 @@ const pm_list_dom = {__esModule: true};
rewiremock("../../static/js/pm_list_dom").with(pm_list_dom); rewiremock("../../static/js/pm_list_dom").with(pm_list_dom);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const pm_conversations = zrequire("pm_conversations"); const pm_conversations = zrequire("pm_conversations");
const pm_list = zrequire("pm_list"); const pm_list = zrequire("pm_list");
@ -296,4 +292,3 @@ run_test("ensure coverage", (override) => {
}, },
); );
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -41,11 +39,6 @@ const stream_data = {__esModule: true};
rewiremock("../../static/js/stream_data").with(stream_data); rewiremock("../../static/js/stream_data").with(stream_data);
const ClipboardJS = noop;
rewiremock("clipboard").with(ClipboardJS);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const user_status = zrequire("user_status"); const user_status = zrequire("user_status");
const message_edit = zrequire("message_edit"); const message_edit = zrequire("message_edit");
@ -53,6 +46,8 @@ const message_edit = zrequire("message_edit");
// Bypass some scary code that runs when we import the module. // Bypass some scary code that runs when we import the module.
const popovers = with_field($.fn, "popover", noop, () => zrequire("popovers")); const popovers = with_field($.fn, "popover", noop, () => zrequire("popovers"));
popovers.__Rewire__("ClipboardJS", noop);
const alice = { const alice = {
email: "alice@example.com", email: "alice@example.com",
full_name: "Alice Smith", full_name: "Alice Smith",
@ -264,5 +259,3 @@ test_ui("actions_popover", (override) => {
handler.call(target, e); handler.call(target, e);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const server_events = {__esModule: true}; const server_events = {__esModule: true};
@ -15,7 +13,6 @@ const reload_state = {
}; };
rewiremock("../../static/js/reload_state").with(reload_state); rewiremock("../../static/js/reload_state").with(reload_state);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const presence = zrequire("presence"); const presence = zrequire("presence");
@ -333,4 +330,3 @@ run_test("update_info_from_event", () => {
last_active: 1000, last_active: 1000,
}); });
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -80,10 +78,8 @@ set_global("current_msg_list", {
}, },
}); });
rewiremock.enable(); const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
const emoji = zrequire("../shared/js/emoji");
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
const emoji = zrequire("emoji", "shared/js/emoji");
const people = zrequire("people"); const people = zrequire("people");
const reactions = zrequire("reactions"); const reactions = zrequire("reactions");
@ -996,4 +992,3 @@ run_test("process_reaction_click bad local id", (override) => {
); );
reactions.process_reaction_click("some-msg-id", "bad-local-id"); reactions.process_reaction_click("some-msg-id", "bad-local-id");
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
let next_id = 0; let next_id = 0;
@ -25,8 +23,6 @@ const message_list = {
rewiremock("../../static/js/message_list").with(message_list); rewiremock("../../static/js/message_list").with(message_list);
rewiremock.enable();
const rs = zrequire("recent_senders"); const rs = zrequire("recent_senders");
zrequire("message_util.js"); zrequire("message_util.js");
@ -228,4 +224,3 @@ run_test("process_message_for_senders", (override) => {
// no changes should take place in this case. // no changes should take place in this case.
rs.update_topics_of_deleted_message_ids([-1]); rs.update_topics_of_deleted_message_ids([-1]);
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -169,8 +167,6 @@ rewiremock("../../static/js/stream_data").with({
id_is_subscribed: () => true, id_is_subscribed: () => true,
}); });
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const rt = zrequire("recent_topics"); const rt = zrequire("recent_topics");
@ -819,4 +815,3 @@ run_test("test_search", () => {
assert.equal(rt.topic_in_search_results("\\", "general", "\\"), true); assert.equal(rt.topic_in_search_results("\\", "general", "\\"), true);
assert.equal(rt.topic_in_search_results("\\", "general", "\\\\"), true); assert.equal(rt.topic_in_search_results("\\", "general", "\\\\"), true);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -13,8 +11,6 @@ rewiremock("../../static/js/rtl").with({
}); });
const page_params = set_global("page_params", {emojiset: "apple"}); const page_params = set_global("page_params", {emojiset: "apple"});
rewiremock.enable();
const rm = zrequire("rendered_markdown"); const rm = zrequire("rendered_markdown");
const people = zrequire("people"); const people = zrequire("people");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
@ -273,4 +269,3 @@ run_test("spoiler-header-empty-fill", () => {
rm.update_elements($content); rm.update_elements($content);
assert.equal(toggle_button_html + "<p>translated: Spoiler</p>", $header.html()); assert.equal(toggle_button_html + "<p>translated: Spoiler</p>", $header.html());
}); });
rewiremock.disable();

View File

@ -2,17 +2,13 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
rewiremock("../../static/js/ui").with({ rewiremock("../../static/js/ui").with({
get_scroll_element: (element) => element, get_scroll_element: (element) => element,
}); });
rewiremock.enable();
const scroll_util = zrequire("scroll_util"); const scroll_util = zrequire("scroll_util");
run_test("scroll_delta", () => { run_test("scroll_delta", () => {
@ -125,4 +121,3 @@ run_test("scroll_element_into_container", () => {
scroll_util.scroll_element_into_container(elem2, container); scroll_util.scroll_element_into_container(elem2, container);
assert.equal(container.scrollTop(), 250 - 100 + 3 + 15); assert.equal(container.scrollTop(), 250 - 100 + 3 + 15);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -35,11 +33,9 @@ rewiremock("../../static/js/search_pill_widget").with({
set_global("setTimeout", (func) => func()); set_global("setTimeout", (func) => func());
rewiremock.enable();
const search = zrequire("search"); const search = zrequire("search");
const search_pill = zrequire("search_pill"); const search_pill = zrequire("search_pill");
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
run_test("clear_search_form", () => { run_test("clear_search_form", () => {
$("#search_query").val("noise"); $("#search_query").val("noise");
@ -350,4 +346,3 @@ run_test("initiate_search", () => {
assert(is_searchbox_text_selected); assert(is_searchbox_text_selected);
assert(is_searchbox_focused); assert(is_searchbox_focused);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -31,8 +29,6 @@ rewiremock("../../static/js/filter").with({
set_global("setTimeout", (func) => func()); set_global("setTimeout", (func) => func());
rewiremock.enable();
const search = zrequire("search"); const search = zrequire("search");
run_test("update_button_visibility", () => { run_test("update_button_visibility", () => {
@ -303,4 +299,3 @@ run_test("initiate_search", () => {
search.initiate_search(); search.initiate_search();
assert.equal($("#search_query").val(), "ver "); assert.equal($("#search_query").val(), "ver ");
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const page_params = set_global("page_params", { const page_params = set_global("page_params", {
@ -15,10 +13,6 @@ rewiremock("../../static/js/message_store").with({
user_ids: () => [], user_ids: () => [],
}); });
rewiremock("../../static/js/narrow").with({});
rewiremock.enable();
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
page_params.realm_email_address_visibility = page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code; settings_config.email_address_visibility_values.admins_only.code;
@ -969,4 +963,3 @@ run_test("multiple_operators_without_pills", () => {
expected = ["is:alerted sender:ted@zulip.com abc"]; expected = ["is:alerted sender:ted@zulip.com abc"];
assert.deepEqual(suggestions.strings, expected); assert.deepEqual(suggestions.strings, expected);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const page_params = set_global("page_params", { const page_params = set_global("page_params", {
@ -13,9 +11,6 @@ const page_params = set_global("page_params", {
rewiremock("../../static/js/message_store").with({ rewiremock("../../static/js/message_store").with({
user_ids: () => [], user_ids: () => [],
}); });
rewiremock("../../static/js/narrow").with({});
rewiremock.enable();
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
page_params.realm_email_address_visibility = page_params.realm_email_address_visibility =
@ -887,4 +882,3 @@ run_test("queries_with_spaces", () => {
expected = ["stream:offi", "stream:office"]; expected = ["stream:offi", "stream:office"];
assert.deepEqual(suggestions.strings, expected); assert.deepEqual(suggestions.strings, expected);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const noop = () => {}; const noop = () => {};
@ -45,10 +43,21 @@ rewiremock("../../static/js/ui_report").with({
}, },
}); });
const message_events = {__esModule: true}; rewiremock("../../static/js/stream_events").with({
rewiremock("../../static/js/message_events").with(message_events); update_property() {
throw new Error("subs update error");
},
});
rewiremock.enable(); const message_events = rewiremock("../../static/js/message_events").with({
__esModule: true,
insert_new_messages() {
throw new Error("insert error");
},
update_messages() {
throw new Error("update error");
},
});
const server_events = zrequire("server_events"); const server_events = zrequire("server_events");
@ -77,17 +86,6 @@ run_test("message_event", (override) => {
const setup = () => { const setup = () => {
server_events.home_view_loaded(); server_events.home_view_loaded();
message_events.insert_new_messages = () => {
throw new Error("insert error");
};
message_events.update_messages = () => {
throw new Error("update error");
};
rewiremock("../../static/js/stream_events").with({
update_property() {
throw new Error("subs update error");
},
});
}; };
run_test("event_dispatch_error", () => { run_test("event_dispatch_error", () => {
@ -141,4 +139,3 @@ run_test("event_edit_message_error", () => {
assert.equal(logs.length, 1); assert.equal(logs.length, 1);
assert.equal(logs[0].more_info, undefined); assert.equal(logs[0].more_info, undefined);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -30,19 +28,15 @@ const bot_data_params = {
}; };
const avatar = {__esModule: true}; const avatar = {__esModule: true};
rewiremock("../../static/js/avatar").with(avatar); rewiremock("../../static/js/avatar").with(avatar);
function ClipboardJS(sel) { function ClipboardJS(sel) {
assert.equal(sel, "#copy_zuliprc"); assert.equal(sel, "#copy_zuliprc");
} }
rewiremock("clipboard").with(ClipboardJS);
rewiremock.enable();
const bot_data = zrequire("bot_data"); const bot_data = zrequire("bot_data");
const settings_bots = zrequire("settings_bots"); const settings_bots = zrequire("settings_bots");
settings_bots.__Rewire__("ClipboardJS", ClipboardJS);
bot_data.initialize(bot_data_params); bot_data.initialize(bot_data_params);
@ -201,5 +195,3 @@ run_test("can_create_new_bots", () => {
page_params.realm_bot_creation_policy = 3; page_params.realm_bot_creation_policy = 3;
assert(!settings_bots.can_create_new_bots()); assert(!settings_bots.can_create_new_bots());
}); });
rewiremock.disable();

View File

@ -2,15 +2,12 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
const upload_widget = {__esModule: true}; const upload_widget = {__esModule: true};
rewiremock("../../static/js/upload_widget").with(upload_widget); rewiremock("../../static/js/upload_widget").with(upload_widget);
rewiremock.enable();
const settings_emoji = zrequire("settings_emoji"); const settings_emoji = zrequire("settings_emoji");
run_test("build_emoji_upload_widget", () => { run_test("build_emoji_upload_widget", () => {
@ -32,4 +29,3 @@ run_test("build_emoji_upload_widget", () => {
settings_emoji.build_emoji_upload_widget(); settings_emoji.build_emoji_upload_widget();
assert(build_widget_stub); assert(build_widget_stub);
}); });
rewiremock.disable();

View File

@ -2,16 +2,13 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
const muting_ui = {__esModule: true}; const muting_ui = {__esModule: true};
rewiremock("../../static/js/muting_ui").with(muting_ui); rewiremock("../../static/js/muting_ui").with(muting_ui);
rewiremock.enable();
const settings_muting = zrequire("settings_muting"); const settings_muting = zrequire("settings_muting");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
@ -92,4 +89,3 @@ run_test("reset", () => {
settings_muting.reset(); settings_muting.reset();
assert.equal(settings_muting.loaded, false); assert.equal(settings_muting.loaded, false);
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -82,8 +80,6 @@ rewiremock("../../static/js/loading").with(_loading);
rewiremock("../../static/js/ui_report").with(_ui_report); rewiremock("../../static/js/ui_report").with(_ui_report);
rewiremock("../../static/js/list_widget").with(_ListWidget); rewiremock("../../static/js/list_widget").with(_ListWidget);
rewiremock.enable();
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const settings_bots = zrequire("settings_bots"); const settings_bots = zrequire("settings_bots");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
@ -1053,5 +1049,3 @@ run_test("misc", () => {
assert.equal(elem.text(), "translated: Disabled"); assert.equal(elem.text(), "translated: Disabled");
assert(elem.hasClass("text-warning")); assert(elem.hasClass("text-warning"));
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -187,5 +185,3 @@ run_test("populate_profile_fields", (override) => {
is_admin: true, is_admin: true,
}); });
}); });
rewiremock.disable();

View File

@ -3,10 +3,9 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -42,8 +41,6 @@ const input_pill = {__esModule: true};
rewiremock("../../static/js/input_pill").with(input_pill); rewiremock("../../static/js/input_pill").with(input_pill);
rewiremock.enable();
const user_pill = zrequire("user_pill"); const user_pill = zrequire("user_pill");
const settings_user_groups = zrequire("settings_user_groups"); const settings_user_groups = zrequire("settings_user_groups");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
@ -880,4 +877,3 @@ test_ui("on_events", () => {
assert(api_endpoint_called); assert(api_endpoint_called);
})(); })();
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -36,8 +34,6 @@ const ui = {
rewiremock("../../static/js/ui").with(ui); rewiremock("../../static/js/ui").with(ui);
rewiremock.enable();
const peer_data = zrequire("peer_data"); const peer_data = zrequire("peer_data");
const people = zrequire("people"); const people = zrequire("people");
const stream_edit = zrequire("stream_edit"); const stream_edit = zrequire("stream_edit");
@ -275,4 +271,3 @@ test_ui("subscriber_pills", () => {
expected_user_ids = potential_denmark_stream_subscribers.concat(fred.user_id); expected_user_ids = potential_denmark_stream_subscribers.concat(fred.user_id);
add_subscribers_handler(event); add_subscribers_handler(event);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -46,13 +44,11 @@ const subs = {
rewiremock("../../static/js/subs").with(subs); rewiremock("../../static/js/subs").with(subs);
rewiremock("../../static/js/overlays").with({streams_open: () => true}); rewiremock("../../static/js/overlays").with({streams_open: () => true});
rewiremock.enable();
const peer_data = zrequire("peer_data"); const peer_data = zrequire("peer_data");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_events = zrequire("stream_events"); const stream_events = zrequire("stream_events");
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
const narrow_state = zrequire("narrow_state"); const narrow_state = zrequire("narrow_state");
const message_view_header = zrequire("message_view_header"); const message_view_header = zrequire("message_view_header");
@ -410,4 +406,3 @@ run_test("remove_deactivated_user_from_all_streams", () => {
// verify that we issue a call to update subscriber count/list UI // verify that we issue a call to update subscriber count/list UI
assert.equal(subs_stub.num_calls, 1); assert.equal(subs_stub.num_calls, 1);
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -25,16 +23,17 @@ rewiremock("../../static/js/keydown_util").with({
handle: noop, handle: noop,
}); });
rewiremock.enable(); rewiremock("../../static/js/ui").with({get_scroll_element: (element) => element});
const {Filter} = zrequire("Filter", "js/filter"); const narrow_state = rewiremock("../../static/js/narrow_state").with({__esModule: true});
const {Filter} = zrequire("../js/filter");
const stream_sort = zrequire("stream_sort"); const stream_sort = zrequire("stream_sort");
const stream_color = zrequire("stream_color"); const stream_color = zrequire("stream_color");
const unread = zrequire("unread"); const unread = zrequire("unread");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const scroll_util = zrequire("scroll_util"); const scroll_util = zrequire("scroll_util");
const stream_list = zrequire("stream_list"); const stream_list = zrequire("stream_list");
rewiremock("../../static/js/ui").with({get_scroll_element: (element) => element});
stream_color.initialize(); stream_color.initialize();
@ -376,17 +375,9 @@ test_ui("zoom_in_and_zoom_out", () => {
assert($("#streams_list").hasClass("zoom-out")); assert($("#streams_list").hasClass("zoom-out"));
}); });
let narrow_state;
test_ui("narrowing", () => { test_ui("narrowing", () => {
initialize_stream_data(); initialize_stream_data();
narrow_state = rewiremock("../../static/js/narrow_state").with({
stream() {
return "devel";
},
topic: noop,
}).mock.value;
topic_list.close = noop; topic_list.close = noop;
topic_list.rebuild = noop; topic_list.rebuild = noop;
topic_list.active_stream_id = noop; topic_list.active_stream_id = noop;
@ -744,4 +735,3 @@ test_ui("create_initial_sidebar_rows", () => {
assert.equal(html_dict.get(1000), "<div>stub-html-devel"); assert.equal(html_dict.get(1000), "<div>stub-html-devel");
assert.equal(html_dict.get(5000), "<div>stub-html-Denmark"); assert.equal(html_dict.get(5000), "<div>stub-html-Denmark");
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -24,8 +22,6 @@ const stream_popover = {__esModule: true};
rewiremock("../../static/js/stream_popover").with(stream_popover); rewiremock("../../static/js/stream_popover").with(stream_popover);
rewiremock.enable();
const stream_list = zrequire("stream_list"); const stream_list = zrequire("stream_list");
function expand_sidebar() { function expand_sidebar() {
@ -196,4 +192,3 @@ run_test("expanding_sidebar", () => {
assert.deepEqual(events, ["popovers.hide_all", "stream_popover.show_streamlist_sidebar"]); assert.deepEqual(events, ["popovers.hide_all", "stream_popover.show_streamlist_sidebar"]);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const channel = {__esModule: true}; const channel = {__esModule: true};
@ -14,8 +12,6 @@ rewiremock("../../static/js/message_list").with(message_list);
const message_util = {__esModule: true}; const message_util = {__esModule: true};
rewiremock("../../static/js/message_util").with(message_util); rewiremock("../../static/js/message_util").with(message_util);
rewiremock.enable();
const unread = zrequire("unread"); const unread = zrequire("unread");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_topic_history = zrequire("stream_topic_history"); const stream_topic_history = zrequire("stream_topic_history");
@ -335,4 +331,3 @@ run_test("server_history_end_to_end", () => {
}); });
assert(on_success_called); assert(on_success_called);
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const channel = {__esModule: true}; const channel = {__esModule: true};
@ -15,8 +13,6 @@ const message_store = {__esModule: true};
rewiremock("../../static/js/message_store").with(message_store); rewiremock("../../static/js/message_store").with(message_store);
rewiremock.enable();
const submessage = zrequire("submessage"); const submessage = zrequire("submessage");
run_test("get_message_events", () => { run_test("get_message_events", () => {
@ -107,4 +103,3 @@ run_test("handle_event", () => {
assert.deepEqual(message.submessages[0], event); assert.deepEqual(message.submessages[0], event);
}); });
rewiremock.disable();

View File

@ -2,10 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {stub_templates} = require("../zjsunit/handlebars"); const {stub_templates} = require("../zjsunit/handlebars");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -27,8 +25,6 @@ rewiremock("../../static/js/hash_util").with({
by_stream_uri: () => {}, by_stream_uri: () => {},
}); });
rewiremock.enable();
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const subs = zrequire("subs"); const subs = zrequire("subs");
@ -211,4 +207,3 @@ run_test("redraw_left_panel", (override) => {
assert(!$(".right .settings").visible()); assert(!$(".right .settings").visible());
assert($(".nothing-selected").visible()); assert($(".nothing-selected").visible());
}); });
rewiremock.disable();

View File

@ -14,7 +14,7 @@ const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document; const document = dom.window.document;
run_test("scrub_realm", () => { run_test("scrub_realm", () => {
zrequire("support", "js/analytics/support"); zrequire("../js/analytics/support");
const click_handler = $("body").get_on_handler("click", ".scrub-realm-button"); const click_handler = $("body").get_on_handler("click", ".scrub-realm-button");
const fake_this = $.create("fake-.scrub-realm-button"); const fake_this = $.create("fake-.scrub-realm-button");

View File

@ -2,34 +2,30 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
rewiremock("../../static/js/resize").with({ rewiremock("../../static/js/resize").with({
resize_stream_filters_container: () => {}, resize_stream_filters_container: () => {},
}); });
rewiremock.enable(); const {Filter} = zrequire("../js/filter");
const {Filter} = zrequire("Filter", "js/filter");
const people = zrequire("people"); const people = zrequire("people");
const pm_list = zrequire("pm_list");
const top_left_corner = zrequire("top_left_corner"); const top_left_corner = zrequire("top_left_corner");
run_test("narrowing", () => { run_test("narrowing", (override) => {
// activating narrow // activating narrow
let pm_expanded; let pm_expanded;
let pm_closed; let pm_closed;
rewiremock("../../static/js/pm_list").with({ override(pm_list, "close", () => {
close() { pm_closed = true;
pm_closed = true; });
}, override(pm_list, "expand", () => {
expand() { pm_expanded = true;
pm_expanded = true;
},
}); });
assert(!pm_expanded); assert(!pm_expanded);
@ -138,4 +134,3 @@ run_test("update_count_in_dom", () => {
assert.equal($("<mentioned-value>").text(), ""); assert.equal($("<mentioned-value>").text(), "");
assert.equal($("<starred-value>").text(), ""); assert.equal($("<starred-value>").text(), "");
}); });
rewiremock.disable();

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {zrequire} = require("../zjsunit/namespace"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const narrow_state = { const narrow_state = {
@ -21,9 +20,6 @@ const muting = {
}, },
}; };
rewiremock("../../static/js/muting").with(muting); rewiremock("../../static/js/muting").with(muting);
rewiremock("../../static/js/message_list").with({});
rewiremock.enable();
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const unread = zrequire("unread"); const unread = zrequire("unread");
@ -152,4 +148,3 @@ run_test("get_list_info unreads", (override) => {
["topic 0", "topic 1", "topic 2", "topic 3", "topic 5", "topic 6", "topic 7", "topic 8"], ["topic 0", "topic 1", "topic 2", "topic 3", "topic 5", "topic 6", "topic 7", "topic 8"],
); );
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const noop = () => {}; const noop = () => {};
@ -24,8 +22,6 @@ const sent_messages = {
rewiremock("../../static/js/sent_messages").with(sent_messages); rewiremock("../../static/js/sent_messages").with(sent_messages);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const transmit = zrequire("transmit"); const transmit = zrequire("transmit");
@ -197,4 +193,3 @@ run_test("reply_message_errors", () => {
message: bogus_message, message: bogus_message,
}); });
}); });
rewiremock.disable();

View File

@ -9,9 +9,7 @@
// become clear as you keep reading. // become clear as you keep reading.
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub"); const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
@ -54,8 +52,6 @@ const topic_list = {__esModule: true};
rewiremock("../../static/js/topic_list").with(topic_list); rewiremock("../../static/js/topic_list").with(topic_list);
rewiremock.enable();
// Let's start with testing a function from util.js. // Let's start with testing a function from util.js.
// //
// We will use our special zrequire helper to import the // We will use our special zrequire helper to import the
@ -197,7 +193,7 @@ run_test("unread", () => {
// We use the second argument of zrequire to find the location of the // We use the second argument of zrequire to find the location of the
// Filter class. // Filter class.
const {Filter} = zrequire("Filter", "js/filter"); const {Filter} = zrequire("../js/filter");
run_test("filter", () => { run_test("filter", () => {
const filter_terms = [ const filter_terms = [
@ -599,7 +595,6 @@ run_test("explore make_stub", (override) => {
*/ */
rewiremock("../../static/js/unread_ops").disable();
unread_ops = zrequire("unread_ops"); unread_ops = zrequire("unread_ops");
run_test("unread_ops", (override) => { run_test("unread_ops", (override) => {
@ -698,7 +693,6 @@ run_test("unread_ops", (override) => {
*/ */
rewiremock("../../static/js/stream_list").disable();
stream_list = zrequire("stream_list"); stream_list = zrequire("stream_list");
const social_stream = { const social_stream = {
@ -835,4 +829,3 @@ run_test("stream_list", (override) => {
sidebar_helper.verify_actions(); sidebar_helper.verify_actions();
topic_list_helper.verify_actions(); topic_list_helper.verify_actions();
}); });
rewiremock.disable();

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace"); const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const typeahead = zrequire("typeahead", "shared/js/typeahead"); const typeahead = zrequire("../shared/js/typeahead");
// The data structures here may be different for // The data structures here may be different for
// different apps; the only key thing is we look // different apps; the only key thing is we look

View File

@ -24,8 +24,8 @@ zrequire("presence");
zrequire("buddy_data"); zrequire("buddy_data");
zrequire("hash_util"); zrequire("hash_util");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("../shared/js/emoji");
const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); const pygments_data = zrequire("../generated/pygments_data.json");
const actual_pygments_data = {...pygments_data}; const actual_pygments_data = {...pygments_data};
const ct = zrequire("composebox_typeahead"); const ct = zrequire("composebox_typeahead");
const th = zrequire("typeahead_helper"); const th = zrequire("typeahead_helper");

View File

@ -7,7 +7,7 @@ const {run_test} = require("../zjsunit/test");
const typing = zrequire("typing"); const typing = zrequire("typing");
const compose_pm_pill = zrequire("compose_pm_pill"); const compose_pm_pill = zrequire("compose_pm_pill");
const typing_status = zrequire("typing_status", "shared/js/typing_status"); const typing_status = zrequire("../shared/js/typing_status");
function make_time(secs) { function make_time(secs) {
// make times semi-realistic // make times semi-realistic

View File

@ -3,9 +3,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
let page_params = set_global("page_params", { let page_params = set_global("page_params", {
@ -18,8 +17,6 @@ const message_store = {__esModule: true};
rewiremock("../../static/js/message_store").with(message_store); rewiremock("../../static/js/message_store").with(message_store);
rewiremock.enable();
const muting = zrequire("muting"); const muting = zrequire("muting");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
@ -696,4 +693,3 @@ run_test("errors", () => {
assert.equal(counts.private_message_count, 0); assert.equal(counts.private_message_count, 0);
test_notifiable_count(counts.home_unread_messages, 0); test_notifiable_count(counts.home_unread_messages, 0);
}); });
rewiremock.disable();

View File

@ -25,7 +25,7 @@ set_global("page_params", {
percent_off: 20, percent_off: 20,
}); });
const helpers = zrequire("helpers", "js/billing/helpers"); const helpers = zrequire("../js/billing/helpers");
run_test("initialize", () => { run_test("initialize", () => {
let token_func; let token_func;
@ -101,7 +101,7 @@ run_test("initialize", () => {
$("#autopay-form").data = (key) => $("#autopay-form").data = (key) =>
document.querySelector("#autopay-form").getAttribute("data-" + key); document.querySelector("#autopay-form").getAttribute("data-" + key);
zrequire("upgrade", "js/billing/upgrade"); zrequire("../js/billing/upgrade");
const e = { const e = {
preventDefault: noop, preventDefault: noop,

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {set_global, zrequire} = require("../zjsunit/namespace");
const {reset_module, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -33,7 +31,11 @@ const plugin_stub = {
}, },
}; };
let upload = zrequire("upload"); const upload = zrequire("upload");
// Even though we stub out Uppy, we need to reference it
// for line coverage purposes.
assert(upload.__get__("Uppy"));
run_test("feature_check", (override) => { run_test("feature_check", (override) => {
const upload_button = $.create("upload-button-stub"); const upload_button = $.create("upload-button-stub");
@ -323,8 +325,6 @@ run_test("upload_files", () => {
assert($("#compose-textarea").val(), "user modified text"); assert($("#compose-textarea").val(), "user modified text");
}); });
rewiremock.enable();
run_test("uppy_config", () => { run_test("uppy_config", () => {
let uppy_stub_called = false; let uppy_stub_called = false;
let uppy_set_meta_called = false; let uppy_set_meta_called = false;
@ -367,8 +367,7 @@ run_test("uppy_config", () => {
}; };
} }
uppy_stub.Plugin = plugin_stub; uppy_stub.Plugin = plugin_stub;
rewiremock("@uppy/core").with(uppy_stub); upload.__Rewire__("Uppy", uppy_stub);
upload = reset_module("upload");
upload.setup_upload({mode: "compose"}); upload.setup_upload({mode: "compose"});
assert.equal(uppy_stub_called, true); assert.equal(uppy_stub_called, true);
@ -505,8 +504,7 @@ run_test("uppy_events", () => {
}; };
} }
uppy_stub.Plugin = plugin_stub; uppy_stub.Plugin = plugin_stub;
rewiremock("@uppy/core").with(uppy_stub); upload.__Rewire__("Uppy", uppy_stub);
upload = reset_module("upload");
upload.setup_upload({mode: "compose"}); upload.setup_upload({mode: "compose"});
assert.equal(Object.keys(callbacks).length, 5); assert.equal(Object.keys(callbacks).length, 5);
@ -692,5 +690,3 @@ run_test("uppy_events", () => {
assert(compose_ui_replace_syntax_called); assert(compose_ui_replace_syntax_called);
assert.equal($("#compose-textarea").val(), "user modified text"); assert.equal($("#compose-textarea").val(), "user modified text");
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
rewiremock("../../static/js/activity").with({ rewiremock("../../static/js/activity").with({
@ -58,8 +56,6 @@ const message_live_update = {__esModule: true};
rewiremock("../../static/js/message_live_update").with(message_live_update); rewiremock("../../static/js/message_live_update").with(message_live_update);
rewiremock.enable();
const people = zrequire("people"); const people = zrequire("people");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const user_events = zrequire("user_events"); const user_events = zrequire("user_events");
@ -216,4 +212,3 @@ run_test("updates", () => {
person = people.get_by_email(test_bot.email); person = people.get_by_email(test_bot.email);
assert.equal(person.bot_owner_id, me.user_id); assert.equal(person.bot_owner_id, me.user_id);
}); });
rewiremock.disable();

View File

@ -2,14 +2,11 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, zrequire} = require("../zjsunit/namespace");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const channel = {__esModule: true}; const channel = {__esModule: true};
rewiremock("../../static/js/channel").with(channel); rewiremock("../../static/js/channel").with(channel);
rewiremock.enable();
const user_status = zrequire("user_status"); const user_status = zrequire("user_status");
function initialize() { function initialize() {
@ -87,4 +84,3 @@ run_test("defensive checks", () => {
user_status.set_away("string"); user_status.set_away("string");
user_status.revoke_away("string"); user_status.revoke_away("string");
}); });
rewiremock.disable();

View File

@ -2,9 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
@ -58,8 +56,6 @@ const narrow_state = {__esModule: true};
rewiremock("../../static/js/narrow_state").with(narrow_state); rewiremock("../../static/js/narrow_state").with(narrow_state);
set_global("current_msg_list", {}); set_global("current_msg_list", {});
rewiremock.enable();
const widgetize = zrequire("widgetize"); const widgetize = zrequire("widgetize");
run_test("activate", (override) => { run_test("activate", (override) => {
@ -181,4 +177,3 @@ run_test("activate", (override) => {
}); });
widgetize.set_widgets_for_list(); widgetize.set_widgets_for_list();
}); });
rewiremock.disable();

View File

@ -81,6 +81,7 @@ test.set_verbose(files.length === 1);
try { try {
for (const file of files) { for (const file of files) {
namespace.start();
namespace.set_global("window", window); namespace.set_global("window", window);
namespace.set_global("to_$", () => window); namespace.set_global("to_$", () => window);
namespace.set_global("location", { namespace.set_global("location", {
@ -100,7 +101,7 @@ try {
blueslip.reset(); blueslip.reset();
} }
namespace.restore(); namespace.finish();
Handlebars.HandlebarsEnvironment.call(Handlebars); Handlebars.HandlebarsEnvironment.call(Handlebars);
} }
} catch (error) { } catch (error) {

View File

@ -1,10 +1,49 @@
"use strict"; "use strict";
const actual_load = require("module")._load;
const path = require("path"); const path = require("path");
const new_globals = new Set(); const new_globals = new Set();
let old_globals = {}; let old_globals = {};
let objs_installed;
let mock_paths = {};
let mocked_paths;
let mock_names;
exports.start = () => {
objs_installed = false;
mock_paths = {};
mocked_paths = new Set();
mock_names = new Set();
};
exports.rewiremock = (fn) => {
if (!fn.startsWith("../../static/js/")) {
throw new Error(`We only mock static/js files`);
}
const short_fn = fn.slice("../../static/js/".length);
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.
`);
}
mock_paths[long_fn] = obj;
mock_names.add(short_fn);
return obj;
},
};
};
exports.set_global = function (name, val) { exports.set_global = function (name, val) {
if (val === null) { if (val === null) {
throw new Error(` throw new Error(`
@ -22,31 +61,46 @@ exports.set_global = function (name, val) {
return val; return val;
}; };
function require_path(name, fn) { exports.zrequire = function (fn) {
if (fn === undefined) { objs_installed = true;
fn = "../../static/js/" + name;
} else if (/^generated\/|^js\/|^shared\/|^third\//.test(fn)) {
// FIXME: Stealing part of the NPM namespace is confusing.
fn = "../../static/" + fn;
}
return fn; // Because we do lazy compilation, we don't reset the
} // _load hook until our test runners calls `finish()`.
require("module")._load = (request, parent, isMain) => {
const long_fn = path.resolve(path.join(path.dirname(parent.filename), request));
if (mock_paths[long_fn]) {
mocked_paths.add(long_fn);
return mock_paths[long_fn];
}
exports.zrequire = function (name, fn) { return actual_load(request, parent, isMain);
return require(require_path(name, fn)); };
}; const full_path = path.resolve(path.join("static/js", fn));
return require(full_path);
exports.reset_module = function (name, fn) {
fn = require_path(name, fn);
delete require.cache[require.resolve(fn)];
return require(fn);
}; };
const staticPath = path.resolve(__dirname, "../../static") + path.sep; const staticPath = path.resolve(__dirname, "../../static") + path.sep;
const templatesPath = staticPath + "templates" + path.sep; const templatesPath = staticPath + "templates" + path.sep;
exports.restore = function () { exports.finish = function () {
/*
Handle cleanup tasks after we've run one module.
Note that we currently do lazy compilation of modules,
so we need to wait till the module tests finish
running to do things like detecting pointless mocks
and resetting our _load hook.
*/
for (const fn of Object.keys(mock_paths)) {
if (!mocked_paths.has(fn)) {
throw new Error(`
You asked to mock ${fn} but we never
saw it during compilation.
`);
}
}
require("module")._load = actual_load;
for (const path of Object.keys(require.cache)) { for (const path of Object.keys(require.cache)) {
if (path.startsWith(staticPath) && !path.startsWith(templatesPath)) { if (path.startsWith(staticPath) && !path.startsWith(templatesPath)) {
delete require.cache[path]; delete require.cache[path];

View File

@ -102,7 +102,6 @@
"openapi-examples-validator": "^4.0.0", "openapi-examples-validator": "^4.0.0",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"puppeteer": "^8.0.0", "puppeteer": "^8.0.0",
"rewiremock": "^3.13.9",
"source-map": "https://github.com/benthemonkey/source-map.git#d95423f77edef6cbb9e21d2d6014c7de85ae220a", "source-map": "https://github.com/benthemonkey/source-map.git#d95423f77edef6cbb9e21d2d6014c7de85ae220a",
"stylelint": "^13.0.0", "stylelint": "^13.0.0",
"stylelint-config-prettier": "^8.0.2", "stylelint-config-prettier": "^8.0.2",

View File

@ -45,4 +45,4 @@ API_FEATURE_LEVEL = 40
# historical commits sharing the same major version, in which case a # historical commits sharing the same major version, in which case a
# minor version bump suffices. # minor version bump suffices.
PROVISION_VERSION = "131.1" PROVISION_VERSION = "132.0"

View File

@ -2235,14 +2235,6 @@ babel-plugin-rewire-ts@^1.4.0:
resolved "https://registry.yarnpkg.com/babel-plugin-rewire-ts/-/babel-plugin-rewire-ts-1.4.0.tgz#6c814d5aa3ef3d8c0d0c7a27891877fb28930e5b" resolved "https://registry.yarnpkg.com/babel-plugin-rewire-ts/-/babel-plugin-rewire-ts-1.4.0.tgz#6c814d5aa3ef3d8c0d0c7a27891877fb28930e5b"
integrity sha512-XVyyWMIx1fNSG42vbUaAro1LANLs/fBW6KurYaeoVjS2U8zLCaow7LKll6zjs1cwcqcbZK2v59zVouPs+JAqxw== integrity sha512-XVyyWMIx1fNSG42vbUaAro1LANLs/fBW6KurYaeoVjS2U8zLCaow7LKll6zjs1cwcqcbZK2v59zVouPs+JAqxw==
babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4=
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"
bail@^1.0.0: bail@^1.0.0:
version "1.0.5" version "1.0.5"
resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.5.tgz#b6fa133404a392cbc1f8c4bf63f5953351e7a776" resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.5.tgz#b6fa133404a392cbc1f8c4bf63f5953351e7a776"
@ -3285,11 +3277,6 @@ compare-cell@^1.0.0:
resolved "https://registry.yarnpkg.com/compare-cell/-/compare-cell-1.0.0.tgz#a9eb708f6e0e41aef7aa566b130f1968dc9e1aaa" resolved "https://registry.yarnpkg.com/compare-cell/-/compare-cell-1.0.0.tgz#a9eb708f6e0e41aef7aa566b130f1968dc9e1aaa"
integrity sha1-qetwj24OQa73qlZrEw8ZaNyeGqo= integrity sha1-qetwj24OQa73qlZrEw8ZaNyeGqo=
compare-module-exports@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/compare-module-exports/-/compare-module-exports-2.1.0.tgz#c4fcb8759e42fb19c52798c510d7f9206b81fa8e"
integrity sha512-3Lc0sTIuX1jmY2K2RrXRJOND6KsRTX2D4v3+eu1PDptsuJZVK4LZc852eZa9I+avj0NrUKlTNgqvccNOH6mbGg==
compare-oriented-cell@^1.0.1: compare-oriented-cell@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/compare-oriented-cell/-/compare-oriented-cell-1.0.1.tgz#6a149feef9dfc4f8fc62358e51dd42effbbdc39e" resolved "https://registry.yarnpkg.com/compare-oriented-cell/-/compare-oriented-cell-1.0.1.tgz#6a149feef9dfc4f8fc62358e51dd42effbbdc39e"
@ -3457,11 +3444,6 @@ core-js-compat@^3.8.1, core-js-compat@^3.9.0:
browserslist "^4.16.3" browserslist "^4.16.3"
semver "7.0.0" semver "7.0.0"
core-js@^2.4.0:
version "2.6.12"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==
core-js@^3.0.1, core-js@^3.6.5: core-js@^3.0.1, core-js@^3.6.5:
version "3.9.1" version "3.9.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.1.tgz#cec8de593db8eb2a85ffb0dbdeb312cb6e5460ae" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.1.tgz#cec8de593db8eb2a85ffb0dbdeb312cb6e5460ae"
@ -7732,11 +7714,6 @@ locate-path@^5.0.0:
dependencies: dependencies:
p-locate "^4.1.0" p-locate "^4.1.0"
lodash._reinterpolate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
lodash.clonedeep@^4.5.0: lodash.clonedeep@^4.5.0:
version "4.5.0" version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
@ -7782,31 +7759,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash.some@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"
integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=
lodash.sortby@^4.7.0: lodash.sortby@^4.7.0:
version "4.7.0" version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
lodash.template@^4.4.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab"
integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A==
dependencies:
lodash._reinterpolate "^3.0.0"
lodash.templatesettings "^4.0.0"
lodash.templatesettings@^4.0.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33"
integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==
dependencies:
lodash._reinterpolate "^3.0.0"
lodash.throttle@^4.1.1: lodash.throttle@^4.1.1:
version "4.1.1" version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
@ -8621,7 +8578,7 @@ node-gyp@^7.1.2:
tar "^6.0.2" tar "^6.0.2"
which "^2.0.2" which "^2.0.2"
"node-libs-browser@^1.0.0 || ^2.0.0", node-libs-browser@^2.1.0, node-libs-browser@^2.2.1: "node-libs-browser@^1.0.0 || ^2.0.0", node-libs-browser@^2.2.1:
version "2.2.1" version "2.2.1"
resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425"
integrity sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q== integrity sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==
@ -9331,7 +9288,7 @@ path-key@^3.1.0:
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
path-parse@^1.0.5, path-parse@^1.0.6: path-parse@^1.0.6:
version "1.0.6" version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
@ -10477,11 +10434,6 @@ regenerate@^1.4.0:
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a"
integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==
regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==
regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4: regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4:
version "0.13.7" version "0.13.7"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
@ -10865,20 +10817,6 @@ reusify@^1.0.4:
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
rewiremock@^3.13.9:
version "3.14.3"
resolved "https://registry.yarnpkg.com/rewiremock/-/rewiremock-3.14.3.tgz#8b42d2b79bb39e8da51cb89159061c2366ea6db3"
integrity sha512-6BaUGfp7NtxBjisxcGN73nNiA2fS2AwhEk/9DMUqxfv5v0aDM1wpOYpj5GSArqsJi07YCfLhkD8C74LAN7+FkQ==
dependencies:
babel-runtime "^6.26.0"
compare-module-exports "^2.1.0"
lodash.some "^4.6.0"
lodash.template "^4.4.0"
node-libs-browser "^2.1.0"
path-parse "^1.0.5"
wipe-node-cache "^2.1.2"
wipe-webpack-cache "^2.1.0"
rgb-regex@^1.0.1: rgb-regex@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1" resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1"
@ -13523,18 +13461,6 @@ winchan@^0.2.1:
resolved "https://registry.yarnpkg.com/winchan/-/winchan-0.2.2.tgz#6766917b88e5e1cb75f455ffc7cc13f51e5c834e" resolved "https://registry.yarnpkg.com/winchan/-/winchan-0.2.2.tgz#6766917b88e5e1cb75f455ffc7cc13f51e5c834e"
integrity sha512-pvN+IFAbRP74n/6mc6phNyCH8oVkzXsto4KCHPJ2AScniAnA1AmeLI03I2BzjePpaClGSI4GUMowzsD3qz5PRQ== integrity sha512-pvN+IFAbRP74n/6mc6phNyCH8oVkzXsto4KCHPJ2AScniAnA1AmeLI03I2BzjePpaClGSI4GUMowzsD3qz5PRQ==
wipe-node-cache@^2.1.0, wipe-node-cache@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/wipe-node-cache/-/wipe-node-cache-2.1.2.tgz#f5aef4bc4366866f89536f3352eb6b9deda53ca0"
integrity sha512-m7NXa8qSxBGMtdQilOu53ctMaIBXy93FOP04EC1Uf4bpsE+r+adfLKwIMIvGbABsznaSNxK/ErD4xXDyY5og9w==
wipe-webpack-cache@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wipe-webpack-cache/-/wipe-webpack-cache-2.1.0.tgz#bc26149f21cf1a3c34752997b96458b567d3e6a1"
integrity sha512-OXzQMGpA7MnQQ8AG+uMl5mWR2ezy6fw1+DMHY+wzYP1qkF1jrek87psLBmhZEj+er4efO/GD4R8jXWFierobaA==
dependencies:
wipe-node-cache "^2.1.0"
word-wrap@^1.2.3, word-wrap@~1.2.3: word-wrap@^1.2.3, word-wrap@~1.2.3:
version "1.2.3" version "1.2.3"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"