mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 18:22:42 -08:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
40
src/main/runtime/mpv-client-runtime-service.test.ts
Normal file
40
src/main/runtime/mpv-client-runtime-service.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createMpvClientRuntimeServiceFactory } from './mpv-client-runtime-service';
|
||||
|
||||
test('mpv runtime service factory constructs client, binds handlers, and connects', () => {
|
||||
const calls: string[] = [];
|
||||
let constructedSocketPath = '';
|
||||
|
||||
class FakeClient {
|
||||
connect(): void {
|
||||
calls.push('connect');
|
||||
}
|
||||
constructor(socketPath: string) {
|
||||
constructedSocketPath = socketPath;
|
||||
calls.push('construct');
|
||||
}
|
||||
}
|
||||
|
||||
const createRuntimeService = createMpvClientRuntimeServiceFactory({
|
||||
createClient: FakeClient,
|
||||
socketPath: '/tmp/mpv.sock',
|
||||
options: {
|
||||
getResolvedConfig: () => ({}),
|
||||
autoStartOverlay: true,
|
||||
setOverlayVisible: () => {},
|
||||
shouldBindVisibleOverlayToMpvSubVisibility: () => false,
|
||||
isVisibleOverlayVisible: () => false,
|
||||
getReconnectTimer: () => null,
|
||||
setReconnectTimer: () => {},
|
||||
},
|
||||
bindEventHandlers: () => {
|
||||
calls.push('bind');
|
||||
},
|
||||
});
|
||||
|
||||
const client = createRuntimeService();
|
||||
assert.ok(client instanceof FakeClient);
|
||||
assert.equal(constructedSocketPath, '/tmp/mpv.sock');
|
||||
assert.deepEqual(calls, ['construct', 'bind', 'connect']);
|
||||
});
|
||||
Reference in New Issue
Block a user