mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-22 00:11:27 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
36
src/main/runtime/ipc-mpv-command-main-deps.test.ts
Normal file
36
src/main/runtime/ipc-mpv-command-main-deps.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createBuildMpvCommandFromIpcRuntimeMainDepsHandler } from './ipc-mpv-command-main-deps';
|
||||
|
||||
test('ipc mpv command main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const deps = createBuildMpvCommandFromIpcRuntimeMainDepsHandler({
|
||||
triggerSubsyncFromConfig: () => calls.push('subsync'),
|
||||
openRuntimeOptionsPalette: () => calls.push('palette'),
|
||||
cycleRuntimeOption: () => ({ ok: false as const, error: 'x' }),
|
||||
showMpvOsd: (text) => calls.push(`osd:${text}`),
|
||||
replayCurrentSubtitle: () => calls.push('replay'),
|
||||
playNextSubtitle: () => calls.push('next'),
|
||||
sendMpvCommand: (command) => calls.push(`cmd:${command.join(':')}`),
|
||||
isMpvConnected: () => true,
|
||||
hasRuntimeOptionsManager: () => false,
|
||||
})();
|
||||
|
||||
deps.triggerSubsyncFromConfig();
|
||||
deps.openRuntimeOptionsPalette();
|
||||
assert.deepEqual(deps.cycleRuntimeOption('anki.nPlusOneMatchMode', 1), { ok: false, error: 'x' });
|
||||
deps.showMpvOsd('hello');
|
||||
deps.replayCurrentSubtitle();
|
||||
deps.playNextSubtitle();
|
||||
deps.sendMpvCommand(['show-text', 'ok']);
|
||||
assert.equal(deps.isMpvConnected(), true);
|
||||
assert.equal(deps.hasRuntimeOptionsManager(), false);
|
||||
assert.deepEqual(calls, [
|
||||
'subsync',
|
||||
'palette',
|
||||
'osd:hello',
|
||||
'replay',
|
||||
'next',
|
||||
'cmd:show-text:ok',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user