mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-03 06:22:41 -08:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
37
src/main/runtime/ipc-bridge-actions-main-deps.test.ts
Normal file
37
src/main/runtime/ipc-bridge-actions-main-deps.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
createBuildHandleMpvCommandFromIpcMainDepsHandler,
|
||||
createBuildRunSubsyncManualFromIpcMainDepsHandler,
|
||||
} from './ipc-bridge-actions-main-deps';
|
||||
|
||||
test('ipc bridge action main deps builders map callbacks', async () => {
|
||||
const calls: string[] = [];
|
||||
|
||||
const handleMpv = createBuildHandleMpvCommandFromIpcMainDepsHandler({
|
||||
handleMpvCommandFromIpcRuntime: (command) => calls.push(`mpv:${command.join(':')}`),
|
||||
buildMpvCommandDeps: () => ({
|
||||
triggerSubsyncFromConfig: async () => {},
|
||||
openRuntimeOptionsPalette: () => {},
|
||||
cycleRuntimeOption: () => ({ ok: false as const, error: 'x' }),
|
||||
showMpvOsd: () => {},
|
||||
replayCurrentSubtitle: () => {},
|
||||
playNextSubtitle: () => {},
|
||||
sendMpvCommand: () => {},
|
||||
isMpvConnected: () => true,
|
||||
hasRuntimeOptionsManager: () => true,
|
||||
}),
|
||||
})();
|
||||
handleMpv.handleMpvCommandFromIpcRuntime(['show-text', 'hello'], handleMpv.buildMpvCommandDeps());
|
||||
assert.equal(handleMpv.buildMpvCommandDeps().isMpvConnected(), true);
|
||||
|
||||
const runSubsync = createBuildRunSubsyncManualFromIpcMainDepsHandler({
|
||||
runManualFromIpc: async (request: { id: string }) => {
|
||||
calls.push(`subsync:${request.id}`);
|
||||
return { ok: true as const };
|
||||
},
|
||||
})();
|
||||
assert.deepEqual(await runSubsync.runManualFromIpc({ id: 'job-1' }), { ok: true });
|
||||
|
||||
assert.deepEqual(calls, ['mpv:show-text:hello', 'subsync:job-1']);
|
||||
});
|
||||
Reference in New Issue
Block a user