mirror of https://github.com/zulip/zulip.git
zjsunit: Remove stub_out_jquery.
We now either use zjquery or do whatever gross things we need to do to work past document.trigger(...) calls or $.now calls explicitly in the tests.
This commit is contained in:
parent
64c7eb67eb
commit
ffe1043bcc
|
@ -2,7 +2,7 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
|
||||
set_global("document", null);
|
||||
|
@ -10,8 +10,6 @@ set_global("page_params", {
|
|||
realm_community_topic_editing_limit_seconds: 259200,
|
||||
});
|
||||
|
||||
stub_out_jquery();
|
||||
|
||||
const message_edit = zrequire("message_edit");
|
||||
|
||||
const get_editability = message_edit.get_editability;
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {make_stub} = require("../zjsunit/stub");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const $ = require("../zjsunit/zjquery");
|
||||
|
||||
// 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
|
||||
|
@ -13,8 +14,14 @@ const {run_test} = require("../zjsunit/test");
|
|||
const noop = function () {};
|
||||
|
||||
set_global("Filter", noop);
|
||||
stub_out_jquery();
|
||||
set_global("document", null);
|
||||
set_global("document", {
|
||||
to_$() {
|
||||
return {
|
||||
trigger() {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const stream_data = set_global("stream_data", {});
|
||||
|
||||
|
@ -75,7 +82,7 @@ run_test("basics", (override) => {
|
|||
|
||||
assert.deepEqual(list.all_messages(), messages);
|
||||
|
||||
override(global.$, "Event", (ev) => {
|
||||
override($, "Event", (ev) => {
|
||||
assert.equal(ev, "message_selected.zulip");
|
||||
});
|
||||
list.select_id(50);
|
||||
|
|
|
@ -2,19 +2,32 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const $ = require("../zjsunit/zjquery");
|
||||
|
||||
const noop = function () {};
|
||||
|
||||
set_global("document", {});
|
||||
set_global("document", {
|
||||
to_$() {
|
||||
return {
|
||||
trigger() {},
|
||||
};
|
||||
},
|
||||
});
|
||||
set_global("addEventListener", noop);
|
||||
stub_out_jquery();
|
||||
|
||||
// Turn off $.now so we can import server_events.
|
||||
set_global("$", {
|
||||
now() {},
|
||||
});
|
||||
|
||||
zrequire("message_store");
|
||||
const server_events = zrequire("server_events");
|
||||
zrequire("sent_messages");
|
||||
|
||||
set_global("$", $);
|
||||
|
||||
const channel = set_global("channel", {});
|
||||
set_global("home_msg_list", {
|
||||
select_id: noop,
|
||||
|
|
|
@ -72,17 +72,6 @@ exports.restore = function () {
|
|||
new_globals.clear();
|
||||
};
|
||||
|
||||
exports.stub_out_jquery = function () {
|
||||
const $ = exports.set_global("$", () => ({
|
||||
on() {},
|
||||
trigger() {},
|
||||
hide() {},
|
||||
removeClass() {},
|
||||
}));
|
||||
$.fn = {};
|
||||
$.now = function () {};
|
||||
};
|
||||
|
||||
exports.with_field = function (obj, field, val, f) {
|
||||
const old_val = obj[field];
|
||||
obj[field] = val;
|
||||
|
|
Loading…
Reference in New Issue