41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { test } from 'node:test';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { parseForkHotkeyReport } from './CallControl';
|
||
|
|
|
||
|
|
test('parseForkHotkeyReport: key reports keep only known boolean flags', () => {
|
||
|
|
assert.deepEqual(
|
||
|
|
parseForkHotkeyReport({
|
||
|
|
type: 'keydown',
|
||
|
|
code: 'Space',
|
||
|
|
repeat: false,
|
||
|
|
ctrlKey: false,
|
||
|
|
altKey: 'yes',
|
||
|
|
metaKey: false,
|
||
|
|
shiftKey: true,
|
||
|
|
editable: false,
|
||
|
|
interactive: true,
|
||
|
|
extra: 1,
|
||
|
|
}),
|
||
|
|
{
|
||
|
|
type: 'keydown',
|
||
|
|
code: 'Space',
|
||
|
|
repeat: false,
|
||
|
|
ctrlKey: false,
|
||
|
|
altKey: false,
|
||
|
|
metaKey: false,
|
||
|
|
shiftKey: true,
|
||
|
|
editable: false,
|
||
|
|
interactive: true,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
assert.equal(parseForkHotkeyReport({ type: 'keyup', code: 'KeyM' })?.type, 'keyup');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('parseForkHotkeyReport: focus reports and junk', () => {
|
||
|
|
assert.deepEqual(parseForkHotkeyReport({ type: 'focus' }), { type: 'focus' });
|
||
|
|
assert.equal(parseForkHotkeyReport({ type: 'keydown' }), null);
|
||
|
|
assert.equal(parseForkHotkeyReport({ type: 'click', code: 'Space' }), null);
|
||
|
|
assert.equal(parseForkHotkeyReport(null), null);
|
||
|
|
assert.equal(parseForkHotkeyReport('keydown'), null);
|
||
|
|
});
|