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/**"],
"globals": {
"document": false,
"reset_module": false,
"set_global": false,
"window": false,
"with_field": false,
"zrequire": false
"window": false
},
"rules": {
"no-sync": "off"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,15 +2,17 @@
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", {
development_environment: true,
});
set_global("compose_ui", {});
const {JSDOM} = require("jsdom");
const {window} = new JSDOM("<!DOCTYPE html><p>Hello world</p>");
const {DOMParser, document} = window;
set_global("$", require("jquery")(window));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert");
const {set_global, with_overrides, zrequire} = require("../zjsunit/namespace");
// Important note on these tests:
//
// 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) {
global.with_overrides((override) => {
with_overrides((override) => {
global.with_stub((stub) => {
override(func_name_to_stub, stub.f);
test_function(stub);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
"use strict";
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
// aspects of the MessageList class. We have to stub out a few functions
// related to views and events to get the tests working.
@ -8,7 +10,7 @@ const {strict: assert} = require("assert");
const noop = function () {};
set_global("Filter", noop);
global.stub_out_jquery();
stub_out_jquery();
set_global("document", null);
set_global("narrow_state", {});
set_global("stream_data", {});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@
const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("page_params", {
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", () => {
$("#search_query").val("noise");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace");
set_global("$", global.make_zjquery());
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,
});
global.patch_builtin("setTimeout", (func) => func());
set_global("setTimeout", (func) => func());
const ev = {
preventDefault: noop,
stopPropagation: noop,

View File

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

View File

@ -4,6 +4,8 @@ const {strict: assert} = require("assert");
const _ = require("lodash");
const {set_global, zrequire} = require("../zjsunit/namespace");
zrequire("user_pill");
zrequire("pill_typeahead");
zrequire("settings_user_groups");
@ -329,7 +331,7 @@ run_test("populate_user_groups", () => {
}
pills.onPillRemove = function (handler) {
global.patch_builtin("setTimeout", (func) => {
set_global("setTimeout", (func) => {
func();
});
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");
api_endpoint_called = true;
(function test_post_success() {
global.patch_builtin("setTimeout", (func) => {
set_global("setTimeout", (func) => {
func();
});
opts.success();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,9 @@
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", {
get_content_element: (element) => element,

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