mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-27 11:35:23 -07:00
test: cut low-value tests, rewrite the rest around behavior, parallelize lanes (#285)
This commit is contained in:
1 parent
4b6842d034
commit
b48083ddd8
368 files changed
+18045
-60331
No files matched your search
@@ -1,51 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createNumericShortcutRuntime, createNumericShortcutSession } from './numeric-shortcut';
|
||||
|
||||
test('createNumericShortcutRuntime creates sessions wired to globalShortcut', () => {
|
||||
const registered: string[] = [];
|
||||
const unregistered: string[] = [];
|
||||
const osd: string[] = [];
|
||||
const handlers = new Map<string, () => void>();
|
||||
|
||||
const runtime = createNumericShortcutRuntime({
|
||||
globalShortcut: {
|
||||
register: (accelerator, callback) => {
|
||||
registered.push(accelerator);
|
||||
handlers.set(accelerator, callback);
|
||||
return true;
|
||||
},
|
||||
unregister: (accelerator) => {
|
||||
unregistered.push(accelerator);
|
||||
handlers.delete(accelerator);
|
||||
},
|
||||
},
|
||||
showMpvOsd: (text) => {
|
||||
osd.push(text);
|
||||
},
|
||||
setTimer: () => setTimeout(() => {}, 1000),
|
||||
clearTimer: (timer) => clearTimeout(timer),
|
||||
});
|
||||
|
||||
const session = runtime.createSession();
|
||||
session.start({
|
||||
timeoutMs: 5000,
|
||||
onDigit: () => {},
|
||||
messages: {
|
||||
prompt: 'Select count',
|
||||
timeout: 'Timed out',
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(session.isActive(), true);
|
||||
assert.ok(registered.includes('1'));
|
||||
assert.ok(registered.includes('Escape'));
|
||||
assert.equal(osd[0], 'Select count');
|
||||
|
||||
handlers.get('Escape')?.();
|
||||
assert.equal(session.isActive(), false);
|
||||
assert.ok(unregistered.includes('Escape'));
|
||||
});
|
||||
import { createNumericShortcutSession } from './numeric-shortcut';
|
||||
|
||||
test('numeric shortcut session handles digit selection and unregisters shortcuts', () => {
|
||||
const handlers = new Map<string, () => void>();
|
||||
|
||||
Reference in new issue
Block a user