mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-13 20:12:54 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createMpvOsdRuntimeHandlers } from './mpv-osd-runtime-handlers';
|
||||
|
||||
test('mpv osd runtime handlers compose append and osd logging flow', async () => {
|
||||
const calls: string[] = [];
|
||||
const runtime = createMpvOsdRuntimeHandlers({
|
||||
appendToMpvLogMainDeps: {
|
||||
logPath: '/tmp/subminer/mpv.log',
|
||||
dirname: () => '/tmp/subminer',
|
||||
mkdir: async () => {},
|
||||
appendFile: async (_targetPath: string, data: string) => {
|
||||
calls.push(`append:${data.trimEnd()}`);
|
||||
},
|
||||
now: () => new Date('2026-02-20T00:00:00.000Z'),
|
||||
},
|
||||
buildShowMpvOsdMainDeps: (appendToMpvLog) => ({
|
||||
appendToMpvLog,
|
||||
showMpvOsdRuntime: (_client, text, fallbackLog) => {
|
||||
calls.push(`show:${text}`);
|
||||
fallbackLog('fallback');
|
||||
},
|
||||
getMpvClient: () => null,
|
||||
logInfo: (line) => calls.push(`info:${line}`),
|
||||
}),
|
||||
});
|
||||
|
||||
runtime.showMpvOsd('hello');
|
||||
await runtime.flushMpvLog();
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
'show:hello',
|
||||
'info:fallback',
|
||||
'append:[2026-02-20T00:00:00.000Z] [OSD] hello',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user