zjsunit: Deglobalize namespace.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-11-30 15:02:16 -08:00 committed by Steve Howell
parent 7b03d48798
commit 425f1789e2
125 changed files with 279 additions and 47 deletions

View File

@ -362,11 +362,7 @@
"files": ["frontend_tests/**"], "files": ["frontend_tests/**"],
"globals": { "globals": {
"document": false, "document": false,
"reset_module": false, "window": false
"set_global": false,
"window": false,
"with_field": false,
"zrequire": false
}, },
"rules": { "rules": {
"no-sync": "off" "no-sync": "off"

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const window_stub = $.create("window-stub"); const window_stub = $.create("window-stub");
set_global("to_$", () => window_stub); set_global("to_$", () => window_stub);

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const params = { const params = {
alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"], alert_words: ["alertone", "alerttwo", "alertthree", "al*rt.*s", ".+", "emoji"],
}; };

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("channel", {}); set_global("channel", {});

View File

@ -5,6 +5,8 @@ const fs = require("fs");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const {set_global, zrequire} = require("../zjsunit/namespace");
const noop = () => {}; const noop = () => {};
const template = fs.readFileSync("templates/corporate/billing.html", "utf-8"); const template = fs.readFileSync("templates/corporate/billing.html", "utf-8");
const dom = new JSDOM(template, {pretendToBeVisual: true}); const dom = new JSDOM(template, {pretendToBeVisual: true});

View File

@ -6,6 +6,8 @@ const fs = require("fs");
const JQuery = require("jquery"); const JQuery = require("jquery");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const {set_global, zrequire} = require("../zjsunit/namespace");
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8"); const template = fs.readFileSync("templates/corporate/upgrade.html", "utf-8");
const dom = new JSDOM(template, {pretendToBeVisual: true}); const dom = new JSDOM(template, {pretendToBeVisual: true});
const jquery = JQuery(dom.window); const jquery = JQuery(dom.window);

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const blueslip_stacktrace = zrequire("blueslip_stacktrace"); const blueslip_stacktrace = zrequire("blueslip_stacktrace");
run_test("clean_path", () => { run_test("clean_path", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const _settings_bots = { const _settings_bots = {
render_bots: () => {}, render_bots: () => {},
}; };

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
const _page_params = {}; const _page_params = {};
set_global("page_params", _page_params); set_global("page_params", _page_params);

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const people = zrequire("people"); const people = zrequire("people");
zrequire("buddy_data"); zrequire("buddy_data");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", {}); set_global("$", {});
set_global("reload", {}); set_global("reload", {});
@ -249,7 +251,7 @@ run_test("retry", () => {
}, },
check_ajax_options(options) { check_ajax_options(options) {
global.patch_builtin("setTimeout", (f, delay) => { set_global("setTimeout", (f, delay) => {
assert.equal(delay, 0); assert.equal(delay, 0);
f(); f();
}); });

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("color_data"); zrequire("color_data");
run_test("pick_color", () => { run_test("pick_color", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("colorspace"); zrequire("colorspace");
run_test("sRGB_to_linear", () => { run_test("sRGB_to_linear", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const noop = () => {}; const noop = () => {};
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("keydown_util"); zrequire("keydown_util");
zrequire("components"); zrequire("components");

View File

@ -5,6 +5,8 @@ const {strict: assert} = require("assert");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
const events = require("./lib/events"); const events = require("./lib/events");
set_global("bridge", false); set_global("bridge", false);
@ -721,7 +723,7 @@ run_test("send_message", () => {
return stub_state; return stub_state;
} }
global.patch_builtin("setTimeout", (func) => { set_global("setTimeout", (func) => {
func(); func();
}); });
global.server_events = { global.server_events = {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const noop = function () {}; const noop = function () {};
const return_false = function () { const return_false = function () {
return false; return false;

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("stream_data"); zrequire("stream_data");
const people = zrequire("people"); const people = zrequire("people");
zrequire("compose_fade"); zrequire("compose_fade");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const people = zrequire("people"); const people = zrequire("people");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const autosize = require("autosize"); const autosize = require("autosize");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
zrequire("compose_ui"); zrequire("compose_ui");
const people = zrequire("people"); const people = zrequire("people");
zrequire("user_status"); zrequire("user_status");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("emoji", "shared/js/emoji");
const typeahead = zrequire("typeahead", "shared/js/typeahead"); const typeahead = zrequire("typeahead", "shared/js/typeahead");
zrequire("compose_state"); zrequire("compose_state");
@ -331,7 +333,7 @@ run_test("content_typeahead_selected", () => {
}, },
}); });
let set_timeout_called = false; let set_timeout_called = false;
global.patch_builtin("setTimeout", (f, time) => { set_global("setTimeout", (f, time) => {
f(); f();
assert.equal(time, 0); assert.equal(time, 0);
set_timeout_called = true; set_timeout_called = true;

View File

@ -2,15 +2,17 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
global.stub_out_jquery(); const {JSDOM} = require("jsdom");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
stub_out_jquery();
set_global("page_params", { set_global("page_params", {
development_environment: true, development_environment: true,
}); });
set_global("compose_ui", {}); set_global("compose_ui", {});
const {JSDOM} = require("jsdom");
const {window} = new JSDOM("<!DOCTYPE html><p>Hello world</p>"); const {window} = new JSDOM("<!DOCTYPE html><p>Hello world</p>");
const {DOMParser, document} = window; const {DOMParser, document} = window;
set_global("$", require("jquery")(window)); set_global("$", require("jquery")(window));

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const noop = function () {}; const noop = function () {};
const events = require("./lib/events"); const events = require("./lib/events");
@ -14,7 +16,7 @@ const typing_person1 = events.typing_person1;
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
global.patch_builtin("setTimeout", (func) => func()); set_global("setTimeout", (func) => func());
set_global("activity", {}); set_global("activity", {});
set_global("alert_words_ui", {}); set_global("alert_words_ui", {});

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const events = require("./lib/events"); const events = require("./lib/events");
const event_fixtures = events.fixtures; const event_fixtures = events.fixtures;

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const XDate = require("xdate"); const XDate = require("xdate");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("localstorage"); zrequire("localstorage");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("dropdown_list_widget"); zrequire("dropdown_list_widget");
zrequire("scroll_util"); zrequire("scroll_util");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("markdown", {}); set_global("markdown", {});
set_global("local_message", { set_global("local_message", {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
const events = require("./lib/events"); const events = require("./lib/events");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {zrequire} = require("../zjsunit/namespace");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("emoji", "shared/js/emoji");
zrequire("emoji_picker"); zrequire("emoji_picker");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const fenced_code = zrequire("fenced_code", "shared/js/fenced_code"); const fenced_code = zrequire("fenced_code", "shared/js/fenced_code");
run_test("get_unused_fence", () => { run_test("get_unused_fence", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const FetchStatus = zrequire("fetch_status"); const FetchStatus = zrequire("fetch_status");
set_global("message_scroll", { set_global("message_scroll", {
hide_loading_older: () => {}, hide_loading_older: () => {},

View File

@ -2,10 +2,12 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
zrequire("unread"); zrequire("unread");
zrequire("stream_data"); zrequire("stream_data");
const people = zrequire("people"); const people = zrequire("people");
global.stub_out_jquery(); stub_out_jquery();
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("message_util", "js/message_util"); zrequire("message_util", "js/message_util");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const {FoldDict} = zrequire("fold_dict"); const {FoldDict} = zrequire("fold_dict");
run_test("basic", () => { run_test("basic", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
// This is a general tour of how to write node tests that // This is a general tour of how to write node tests that
// may also give you some quick insight on how the Zulip // may also give you some quick insight on how the Zulip
// browser app is constructed. Let's start with testing // browser app is constructed. Let's start with testing

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("hash_util"); zrequire("hash_util");
zrequire("stream_data"); zrequire("stream_data");
const people = zrequire("people"); const people = zrequire("people");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const window_stub = $.create("window-stub"); const window_stub = $.create("window-stub");
set_global("location", { set_global("location", {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, with_overrides, zrequire} = require("../zjsunit/namespace");
// Important note on these tests: // Important note on these tests:
// //
// The way the Zulip hotkey tests work is as follows. First, we set // The way the Zulip hotkey tests work is as follows. First, we set
@ -80,7 +82,7 @@ function return_false() {
} }
function stubbing(func_name_to_stub, test_function) { function stubbing(func_name_to_stub, test_function) {
global.with_overrides((override) => { with_overrides((override) => {
global.with_stub((stub) => { global.with_stub((stub) => {
override(func_name_to_stub, stub.f); override(func_name_to_stub, stub.f);
test_function(stub); test_function(stub);

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("templates"); zrequire("templates");
// We download our translations in `page_params` (which // We download our translations in `page_params` (which

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("input_pill"); zrequire("input_pill");

View File

@ -1,5 +1,7 @@
"use strict"; "use strict";
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("keydown_util"); zrequire("keydown_util");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const {LazySet} = zrequire("lazy_set"); const {LazySet} = zrequire("lazy_set");
/* /*

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("rows"); zrequire("rows");
zrequire("lightbox"); zrequire("lightbox");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("list_cursor"); zrequire("list_cursor");
run_test("config errors", () => { run_test("config errors", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("list_render"); zrequire("list_render");
// We need these stubs to get by instanceof checks. // We need these stubs to get by instanceof checks.

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
zrequire("hash_util"); zrequire("hash_util");
const emoji = zrequire("emoji", "shared/js/emoji"); const emoji = zrequire("emoji", "shared/js/emoji");

View File

@ -9,6 +9,8 @@
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
const markdown_config = zrequire("markdown_config"); const markdown_config = zrequire("markdown_config");
set_global("page_params", {}); set_global("page_params", {});

View File

@ -2,12 +2,14 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
set_global("document", null); set_global("document", null);
set_global("page_params", { set_global("page_params", {
realm_community_topic_editing_limit_seconds: 86400, realm_community_topic_editing_limit_seconds: 86400,
}); });
global.stub_out_jquery(); stub_out_jquery();
zrequire("message_edit"); zrequire("message_edit");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("message_events"); zrequire("message_events");
zrequire("message_store"); zrequire("message_store");
zrequire("muting"); zrequire("muting");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("document", "document-stub"); set_global("document", "document-stub");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("unread"); zrequire("unread");
zrequire("unread_ops"); zrequire("unread_ops");
zrequire("message_flags"); zrequire("message_flags");

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
// These unit tests for static/js/message_list.js emphasize the model-ish // These unit tests for static/js/message_list.js emphasize the model-ish
// aspects of the MessageList class. We have to stub out a few functions // aspects of the MessageList class. We have to stub out a few functions
// related to views and events to get the tests working. // related to views and events to get the tests working.
@ -8,7 +10,7 @@ const {strict: assert} = require("assert");
const noop = function () {}; const noop = function () {};
set_global("Filter", noop); set_global("Filter", noop);
global.stub_out_jquery(); stub_out_jquery();
set_global("document", null); set_global("document", null);
set_global("narrow_state", {}); set_global("narrow_state", {});
set_global("stream_data", {}); set_global("stream_data", {});

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("unread"); zrequire("unread");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
@ -11,7 +13,7 @@ zrequire("MessageListData", "js/message_list_data");
set_global("page_params", {}); set_global("page_params", {});
set_global("muting", {}); set_global("muting", {});
global.patch_builtin("setTimeout", (f, delay) => { set_global("setTimeout", (f, delay) => {
assert.equal(delay, 0); assert.equal(delay, 0);
return f(); return f();
}); });

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("document", "document-stub"); set_global("document", "document-stub");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const util = zrequire("util"); const util = zrequire("util");
zrequire("pm_conversations"); zrequire("pm_conversations");
const people = zrequire("people"); const people = zrequire("people");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("timerender"); zrequire("timerender");
zrequire("muting"); zrequire("muting");
zrequire("stream_data"); zrequire("stream_data");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("hash_util"); zrequire("hash_util");
zrequire("hashchange"); zrequire("hashchange");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const util = zrequire("util"); const util = zrequire("util");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
@ -54,7 +56,7 @@ set_global("search_pill_widget", {
// //
// We have strange hacks in narrow.activate to sleep 0 // We have strange hacks in narrow.activate to sleep 0
// seconds. // seconds.
global.patch_builtin("setTimeout", (f, t) => { set_global("setTimeout", (f, t) => {
assert.equal(t, 0); assert.equal(t, 0);
f(); f();
}); });

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
zrequire("FetchStatus", "js/fetch_status"); zrequire("FetchStatus", "js/fetch_status");
zrequire("MessageListData", "js/message_list_data"); zrequire("MessageListData", "js/message_list_data");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const people = zrequire("people"); const people = zrequire("people");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
zrequire("stream_data"); zrequire("stream_data");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");
const people = zrequire("people"); const people = zrequire("people");
zrequire("stream_data"); zrequire("stream_data");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
// Dependencies // Dependencies
set_global( set_global(
"$", "$",

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn")); set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn"));
zrequire("common"); zrequire("common");

View File

@ -6,6 +6,8 @@ const _ = require("lodash");
const moment = require("moment-timezone"); const moment = require("moment-timezone");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
const people = rewiremock.proxy(() => zrequire("people"), { const people = rewiremock.proxy(() => zrequire("people"), {
"moment-timezone": () => moment("20130208T080910"), "moment-timezone": () => moment("20130208T080910"),
}); });

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const people = zrequire("people"); const people = zrequire("people");
const return_false = function () { const return_false = function () {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const pmc = zrequire("pm_conversations"); const pmc = zrequire("pm_conversations");
run_test("partners", () => { run_test("partners", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("narrow_state", {}); set_global("narrow_state", {});

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("poll_widget"); zrequire("poll_widget");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("hash_util"); zrequire("hash_util");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const XDate = require("xdate"); const XDate = require("xdate");
const {set_global, zrequire} = require("../zjsunit/namespace");
const people = zrequire("people"); const people = zrequire("people");
zrequire("presence"); zrequire("presence");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
set_global("document", "document-stub"); set_global("document", "document-stub");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const rs = zrequire("recent_senders"); const rs = zrequire("recent_senders");
let next_id = 0; let next_id = 0;

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {reset_module, set_global, zrequire} = require("../zjsunit/namespace");
zrequire("message_util"); zrequire("message_util");
const noop = () => {}; const noop = () => {};

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const rm = zrequire("rendered_markdown"); const rm = zrequire("rendered_markdown");
const people = zrequire("people"); const people = zrequire("people");
zrequire("user_groups"); zrequire("user_groups");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const rtl = zrequire("rtl"); const rtl = zrequire("rtl");
run_test("get_direction", () => { run_test("get_direction", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("schema"); zrequire("schema");
run_test("basics", () => { run_test("basics", () => {

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("scroll_util"); zrequire("scroll_util");
set_global("ui", { set_global("ui", {
get_scroll_element: (element) => element, get_scroll_element: (element) => element,

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", { set_global("page_params", {
search_pills_enabled: true, search_pills_enabled: true,
}); });
@ -28,7 +30,7 @@ set_global("search_pill_widget", {
}, },
}); });
global.patch_builtin("setTimeout", (func) => func()); set_global("setTimeout", (func) => func());
run_test("clear_search_form", () => { run_test("clear_search_form", () => {
$("#search_query").val("noise"); $("#search_query").val("noise");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", { set_global("page_params", {
search_pills_enabled: false, search_pills_enabled: false,
}); });
@ -21,7 +23,7 @@ set_global("ui_util", {
set_global("narrow", {}); set_global("narrow", {});
set_global("Filter", {}); set_global("Filter", {});
global.patch_builtin("setTimeout", (func) => func()); set_global("setTimeout", (func) => func());
run_test("update_button_visibility", () => { run_test("update_button_visibility", () => {
const search_query = $("#search_query"); const search_query = $("#search_query");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("search_pill"); zrequire("search_pill");
zrequire("input_pill"); zrequire("input_pill");
zrequire("Filter", "js/filter"); zrequire("Filter", "js/filter");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", { set_global("page_params", {
search_pills_enabled: true, search_pills_enabled: true,
}); });

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", { set_global("page_params", {
search_pills_enabled: false, search_pills_enabled: false,
}); });

View File

@ -2,11 +2,13 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
const noop = function () {}; const noop = function () {};
set_global("document", {}); set_global("document", {});
set_global("addEventListener", noop); set_global("addEventListener", noop);
global.stub_out_jquery(); stub_out_jquery();
zrequire("message_store"); zrequire("message_store");
zrequire("server_events_dispatch"); zrequire("server_events_dispatch");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", { set_global("page_params", {
realm_uri: "https://chat.example.com", realm_uri: "https://chat.example.com",
realm_embedded_bots: [ realm_embedded_bots: [

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const settings_data = zrequire("settings_data"); const settings_data = zrequire("settings_data");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("upload_widget", {}); set_global("upload_widget", {});
zrequire("settings_emoji"); zrequire("settings_emoji");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("XDate", zrequire("XDate", "xdate")); set_global("XDate", zrequire("XDate", "xdate"));

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
const noop = () => {}; const noop = () => {};
@ -200,7 +202,7 @@ function test_submit_settings_form(submit_form) {
realm_create_stream_policy: settings_config.create_stream_policy_values.by_members.code, realm_create_stream_policy: settings_config.create_stream_policy_values.by_members.code,
}); });
global.patch_builtin("setTimeout", (func) => func()); set_global("setTimeout", (func) => func());
const ev = { const ev = {
preventDefault: noop, preventDefault: noop,
stopPropagation: noop, stopPropagation: noop,

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node"); const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", {}); set_global("page_params", {});
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
set_global("loading", {}); set_global("loading", {});

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("user_pill"); zrequire("user_pill");
zrequire("pill_typeahead"); zrequire("pill_typeahead");
zrequire("settings_user_groups"); zrequire("settings_user_groups");
@ -329,7 +331,7 @@ run_test("populate_user_groups", () => {
} }
pills.onPillRemove = function (handler) { pills.onPillRemove = function (handler) {
global.patch_builtin("setTimeout", (func) => { set_global("setTimeout", (func) => {
func(); func();
}); });
realm_user_group.members = new Set([2, 31]); realm_user_group.members = new Set([2, 31]);
@ -789,7 +791,7 @@ run_test("on_events", () => {
assert.equal(opts.data.description, "translated: All mobile members"); assert.equal(opts.data.description, "translated: All mobile members");
api_endpoint_called = true; api_endpoint_called = true;
(function test_post_success() { (function test_post_success() {
global.patch_builtin("setTimeout", (func) => { set_global("setTimeout", (func) => {
func(); func();
}); });
opts.success(); opts.success();

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());
zrequire("spoilers"); zrequire("spoilers");

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash"); const _ = require("lodash");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
set_global("page_params", { set_global("page_params", {
is_admin: false, is_admin: false,
realm_users: [], realm_users: [],
@ -13,7 +15,7 @@ set_global("page_params", {
set_global("$", () => {}); set_global("$", () => {});
set_global("document", null); set_global("document", null);
global.stub_out_jquery(); stub_out_jquery();
zrequire("color_data"); zrequire("color_data");
zrequire("hash_util"); zrequire("hash_util");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {LazySet} = zrequire("lazy_set"); const {LazySet} = zrequire("lazy_set");
const noop = () => {}; const noop = () => {};

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const noop = function () {}; const noop = function () {};
const return_true = function () { const return_true = function () {
return true; return true;

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("document", "document-stub"); set_global("document", "document-stub");
set_global("$", global.make_zjquery()); set_global("$", global.make_zjquery());

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("stream_data"); zrequire("stream_data");
zrequire("stream_pill"); zrequire("stream_pill");

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
// This tests the stream searching functionality which currently // This tests the stream searching functionality which currently
// lives in stream_list.js. // lives in stream_list.js.

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
zrequire("stream_data"); zrequire("stream_data");
zrequire("stream_sort"); zrequire("stream_sort");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("unread"); zrequire("unread");
zrequire("stream_data"); zrequire("stream_data");
zrequire("stream_topic_history"); zrequire("stream_topic_history");

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("submessage"); zrequire("submessage");
set_global("channel", {}); set_global("channel", {});

View File

@ -2,7 +2,9 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
global.stub_out_jquery(); const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
stub_out_jquery();
set_global("ui", { set_global("ui", {
get_content_element: (element) => element, get_content_element: (element) => element,

Some files were not shown because too many files have changed in this diff Show More