Files
zulip/frontend_tests/node_tests/keydown_util.js
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00

42 lines
732 B
JavaScript

"use strict";
set_global("$", global.make_zjquery());
zrequire("keydown_util");
run_test("test_early_returns", () => {
const stub = $.create("stub");
const opts = {
elem: stub,
handlers: {
left_arrow: () => {
throw 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);
});