mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-22 02:56:24 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
38
src/main/runtime/numeric-shortcut-session-main-deps.test.ts
Normal file
38
src/main/runtime/numeric-shortcut-session-main-deps.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
createBuildCancelNumericShortcutSessionMainDepsHandler,
|
||||
createBuildStartNumericShortcutSessionMainDepsHandler,
|
||||
} from './numeric-shortcut-session-main-deps';
|
||||
|
||||
test('numeric shortcut session main deps builders map callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const session = {
|
||||
start: () => calls.push('start'),
|
||||
cancel: () => calls.push('cancel'),
|
||||
};
|
||||
|
||||
const cancel = createBuildCancelNumericShortcutSessionMainDepsHandler({ session })();
|
||||
cancel.session.cancel();
|
||||
|
||||
const start = createBuildStartNumericShortcutSessionMainDepsHandler({
|
||||
session,
|
||||
onDigit: (digit) => calls.push(`digit:${digit}`),
|
||||
messages: {
|
||||
prompt: 'prompt',
|
||||
timeout: 'timeout',
|
||||
cancelled: 'cancelled',
|
||||
},
|
||||
})();
|
||||
start.session.start({
|
||||
timeoutMs: 100,
|
||||
onDigit: () => {},
|
||||
messages: start.messages,
|
||||
});
|
||||
start.onDigit(4);
|
||||
assert.equal(start.messages.prompt, 'prompt');
|
||||
assert.equal(start.messages.timeout, 'timeout');
|
||||
assert.equal(start.messages.cancelled, 'cancelled');
|
||||
|
||||
assert.deepEqual(calls, ['cancel', 'start', 'digit:4']);
|
||||
});
|
||||
Reference in New Issue
Block a user