mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
refactor: normalize remaining main runtime dependency setup
This commit is contained in:
32
src/main/runtime/numeric-shortcut-runtime-main-deps.test.ts
Normal file
32
src/main/runtime/numeric-shortcut-runtime-main-deps.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createBuildNumericShortcutRuntimeMainDepsHandler } from './numeric-shortcut-runtime-main-deps';
|
||||
|
||||
test('numeric shortcut runtime main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const deps = createBuildNumericShortcutRuntimeMainDepsHandler({
|
||||
globalShortcut: {
|
||||
register: () => true,
|
||||
unregister: () => {
|
||||
calls.push('unregister');
|
||||
},
|
||||
},
|
||||
showMpvOsd: (text) => calls.push(`osd:${text}`),
|
||||
setTimer: (handler) => {
|
||||
calls.push('timer');
|
||||
handler();
|
||||
return 1 as never;
|
||||
},
|
||||
clearTimer: () => {
|
||||
calls.push('clear');
|
||||
},
|
||||
})();
|
||||
|
||||
assert.equal(deps.globalShortcut.register('1', () => {}), true);
|
||||
deps.globalShortcut.unregister('1');
|
||||
deps.showMpvOsd('x');
|
||||
deps.setTimer(() => calls.push('tick'), 1000);
|
||||
deps.clearTimer(1 as never);
|
||||
|
||||
assert.deepEqual(calls, ['unregister', 'osd:x', 'timer', 'tick', 'clear']);
|
||||
});
|
||||
Reference in New Issue
Block a user