mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 16:14:02 +00:00
We no longer export make_zjquery(). We now instead have a singleton zjquery instance that we attach to global.$ in index.js. We call $.clear_all_elements() before each module. (We will soon get even more aggressive about doing it in run_test.) Test functions can still override $ with set_global. A good example of this is copy_and_paste using the real jquery module. We no longer exempt $ as a global variable, so test modules that use the zjquery $ need to do: const $ = require("../zjsunit/zjquery");
44 lines
857 B
JavaScript
44 lines
857 B
JavaScript
"use strict";
|
|
|
|
const {zrequire} = require("../zjsunit/namespace");
|
|
const {run_test} = require("../zjsunit/test");
|
|
const $ = require("../zjsunit/zjquery");
|
|
|
|
const keydown_util = zrequire("keydown_util");
|
|
|
|
run_test("test_early_returns", () => {
|
|
const stub = $.create("stub");
|
|
const opts = {
|
|
elem: stub,
|
|
handlers: {
|
|
left_arrow: () => {
|
|
throw new Error("do not dispatch this with alt key");
|
|
},
|
|
},
|
|
};
|
|
|
|
keydown_util.handle(opts);
|
|
|
|
const e1 = {
|
|
type: "keydown",
|
|
which: 17, // not in keys
|
|
};
|
|
|
|
stub.trigger(e1);
|
|
|
|
const e2 = {
|
|
type: "keydown",
|
|
which: 13, // no handler
|
|
};
|
|
|
|
stub.trigger(e2);
|
|
|
|
const e3 = {
|
|
type: "keydown",
|
|
which: 37,
|
|
altKey: true, // let browser handle
|
|
};
|
|
|
|
stub.trigger(e3);
|
|
});
|