2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2021-02-21 15:38:51 +01:00
|
|
|
const {zrequire} = require("../zjsunit/namespace");
|
2020-12-01 00:39:47 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
2021-02-21 15:38:51 +01:00
|
|
|
const $ = require("../zjsunit/zjquery");
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2021-02-10 04:53:22 +01:00
|
|
|
const keydown_util = zrequire("keydown_util");
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("test_early_returns", () => {
|
|
|
|
const stub = $.create("stub");
|
2018-12-04 19:15:31 +01:00
|
|
|
const opts = {
|
2018-07-23 00:45:46 +02:00
|
|
|
elem: stub,
|
2018-12-04 19:15:31 +01:00
|
|
|
handlers: {
|
|
|
|
left_arrow: () => {
|
2020-10-07 09:58:04 +02:00
|
|
|
throw new Error("do not dispatch this with alt key");
|
2018-12-04 19:15:31 +01:00
|
|
|
},
|
|
|
|
},
|
2018-07-23 00:45:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
keydown_util.handle(opts);
|
|
|
|
|
2018-12-04 19:15:31 +01:00
|
|
|
const e1 = {
|
2020-07-20 21:24:26 +02:00
|
|
|
type: "keydown",
|
2018-07-23 00:45:46 +02:00
|
|
|
which: 17, // not in keys
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:24:26 +02:00
|
|
|
stub.trigger(e1);
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2018-12-04 19:15:31 +01:00
|
|
|
const e2 = {
|
2020-07-20 21:24:26 +02:00
|
|
|
type: "keydown",
|
2018-07-23 00:45:46 +02:00
|
|
|
which: 13, // no handler
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:24:26 +02:00
|
|
|
stub.trigger(e2);
|
2018-12-04 19:15:31 +01:00
|
|
|
|
|
|
|
const e3 = {
|
2020-07-20 21:24:26 +02:00
|
|
|
type: "keydown",
|
2018-12-04 19:15:31 +01:00
|
|
|
which: 37,
|
|
|
|
altKey: true, // let browser handle
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:24:26 +02:00
|
|
|
stub.trigger(e3);
|
2018-07-23 00:45:46 +02:00
|
|
|
});
|