48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { test } from 'node:test';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { isBindableCallKey } from './callKeybind';
|
||
|
|
|
||
|
|
test('isBindableCallKey rejects navigation-critical codes', () => {
|
||
|
|
[
|
||
|
|
'Escape',
|
||
|
|
'Tab',
|
||
|
|
'Enter',
|
||
|
|
'NumpadEnter',
|
||
|
|
'ArrowUp',
|
||
|
|
'ArrowDown',
|
||
|
|
'ArrowLeft',
|
||
|
|
'ArrowRight',
|
||
|
|
'Home',
|
||
|
|
'End',
|
||
|
|
'PageUp',
|
||
|
|
'PageDown',
|
||
|
|
].forEach((code) => {
|
||
|
|
assert.equal(isBindableCallKey(code), false, `${code} should be unbindable`);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
test('isBindableCallKey rejects bare modifier codes', () => {
|
||
|
|
[
|
||
|
|
'ShiftLeft',
|
||
|
|
'ShiftRight',
|
||
|
|
'ControlLeft',
|
||
|
|
'ControlRight',
|
||
|
|
'AltLeft',
|
||
|
|
'AltRight',
|
||
|
|
'MetaLeft',
|
||
|
|
'MetaRight',
|
||
|
|
].forEach((code) => {
|
||
|
|
assert.equal(isBindableCallKey(code), false, `${code} should be unbindable`);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
test('isBindableCallKey accepts ordinary keys', () => {
|
||
|
|
['Space', 'KeyM', 'KeyQ', 'Digit1', 'F13'].forEach((code) => {
|
||
|
|
assert.equal(isBindableCallKey(code), true, `${code} should be bindable`);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
test('isBindableCallKey rejects the empty string', () => {
|
||
|
|
assert.equal(isBindableCallKey(''), false);
|
||
|
|
});
|