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:
60
src/main/runtime/overlay-main-actions.test.ts
Normal file
60
src/main/runtime/overlay-main-actions.test.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
createAppendClipboardVideoToQueueHandler,
|
||||
createHandleOverlayModalClosedHandler,
|
||||
createSetOverlayVisibleHandler,
|
||||
createToggleOverlayHandler,
|
||||
} from './overlay-main-actions';
|
||||
|
||||
test('set overlay visible handler delegates to visible overlay setter', () => {
|
||||
const calls: string[] = [];
|
||||
const setOverlayVisible = createSetOverlayVisibleHandler({
|
||||
setVisibleOverlayVisible: (visible) => calls.push(`set:${visible}`),
|
||||
});
|
||||
|
||||
setOverlayVisible(true);
|
||||
assert.deepEqual(calls, ['set:true']);
|
||||
});
|
||||
|
||||
test('toggle overlay handler delegates to visible toggle', () => {
|
||||
const calls: string[] = [];
|
||||
const toggleOverlay = createToggleOverlayHandler({
|
||||
toggleVisibleOverlay: () => calls.push('toggle'),
|
||||
});
|
||||
|
||||
toggleOverlay();
|
||||
assert.deepEqual(calls, ['toggle']);
|
||||
});
|
||||
|
||||
test('overlay modal closed handler delegates to runtime handler', () => {
|
||||
const calls: string[] = [];
|
||||
const handleClosed = createHandleOverlayModalClosedHandler({
|
||||
handleOverlayModalClosedRuntime: (modal) => calls.push(`closed:${modal}`),
|
||||
});
|
||||
|
||||
handleClosed('runtime-options');
|
||||
assert.deepEqual(calls, ['closed:runtime-options']);
|
||||
});
|
||||
|
||||
test('append clipboard queue handler forwards runtime deps and result', () => {
|
||||
const calls: string[] = [];
|
||||
const mpvClient = { connected: true };
|
||||
const appendClipboardVideoToQueue = createAppendClipboardVideoToQueueHandler({
|
||||
appendClipboardVideoToQueueRuntime: (options) => {
|
||||
assert.equal(options.getMpvClient(), mpvClient);
|
||||
assert.equal(options.readClipboardText(), '/tmp/video.mkv');
|
||||
options.showMpvOsd('queued');
|
||||
options.sendMpvCommand(['loadfile', '/tmp/video.mkv', 'append']);
|
||||
return { ok: true, message: 'ok' };
|
||||
},
|
||||
getMpvClient: () => mpvClient,
|
||||
readClipboardText: () => '/tmp/video.mkv',
|
||||
showMpvOsd: (text) => calls.push(`osd:${text}`),
|
||||
sendMpvCommand: (command) => calls.push(`mpv:${command.join(':')}`),
|
||||
});
|
||||
|
||||
const result = appendClipboardVideoToQueue();
|
||||
assert.deepEqual(result, { ok: true, message: 'ok' });
|
||||
assert.deepEqual(calls, ['osd:queued', 'mpv:loadfile:/tmp/video.mkv:append']);
|
||||
});
|
||||
Reference in New Issue
Block a user