mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-25 00:11:26 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createNumericShortcutSessionRuntimeHandlers } from './numeric-shortcut-session-runtime-handlers';
|
||||
|
||||
test('numeric shortcut session runtime handlers compose cancel/start handlers', () => {
|
||||
const calls: string[] = [];
|
||||
const createSession = (name: string) => ({
|
||||
start: ({ timeoutMs, onDigit }: { timeoutMs: number; onDigit: (digit: number) => void }) => {
|
||||
calls.push(`${name}:start:${timeoutMs}`);
|
||||
onDigit(3);
|
||||
},
|
||||
cancel: () => calls.push(`${name}:cancel`),
|
||||
});
|
||||
|
||||
const runtime = createNumericShortcutSessionRuntimeHandlers({
|
||||
multiCopySession: createSession('multi-copy'),
|
||||
mineSentenceSession: createSession('mine-sentence'),
|
||||
onMultiCopyDigit: (count) => calls.push(`multi-copy:digit:${count}`),
|
||||
onMineSentenceDigit: (count) => calls.push(`mine-sentence:digit:${count}`),
|
||||
});
|
||||
|
||||
runtime.cancelPendingMultiCopy();
|
||||
runtime.startPendingMultiCopy(500);
|
||||
runtime.cancelPendingMineSentenceMultiple();
|
||||
runtime.startPendingMineSentenceMultiple(700);
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
'multi-copy:cancel',
|
||||
'multi-copy:start:500',
|
||||
'multi-copy:digit:3',
|
||||
'mine-sentence:cancel',
|
||||
'mine-sentence:start:700',
|
||||
'mine-sentence:digit:3',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user