mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-07 19:21:32 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
createBuildBroadcastRuntimeOptionsChangedMainDepsHandler,
|
||||
createBuildGetRuntimeOptionsStateMainDepsHandler,
|
||||
createBuildOpenRuntimeOptionsPaletteMainDepsHandler,
|
||||
createBuildRestorePreviousSecondarySubVisibilityMainDepsHandler,
|
||||
createBuildSendToActiveOverlayWindowMainDepsHandler,
|
||||
createBuildSetOverlayDebugVisualizationEnabledMainDepsHandler,
|
||||
} from './overlay-runtime-main-actions-main-deps';
|
||||
|
||||
test('get runtime options state main deps builder maps callbacks', () => {
|
||||
const manager = { listOptions: () => [] };
|
||||
const deps = createBuildGetRuntimeOptionsStateMainDepsHandler({
|
||||
getRuntimeOptionsManager: () => manager,
|
||||
})();
|
||||
assert.equal(deps.getRuntimeOptionsManager(), manager);
|
||||
});
|
||||
|
||||
test('restore secondary sub visibility main deps builder maps callbacks', () => {
|
||||
const deps = createBuildRestorePreviousSecondarySubVisibilityMainDepsHandler({
|
||||
getMpvClient: () => ({ connected: true, restorePreviousSecondarySubVisibility: () => {} }),
|
||||
})();
|
||||
assert.equal(deps.getMpvClient()?.connected, true);
|
||||
});
|
||||
|
||||
test('broadcast runtime options changed main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const deps = createBuildBroadcastRuntimeOptionsChangedMainDepsHandler({
|
||||
broadcastRuntimeOptionsChangedRuntime: () => calls.push('broadcast-runtime'),
|
||||
getRuntimeOptionsState: () => [],
|
||||
broadcastToOverlayWindows: (channel) => calls.push(channel),
|
||||
})();
|
||||
|
||||
deps.broadcastRuntimeOptionsChangedRuntime(() => [], () => {});
|
||||
deps.broadcastToOverlayWindows('runtime-options:changed');
|
||||
assert.deepEqual(deps.getRuntimeOptionsState(), []);
|
||||
assert.deepEqual(calls, ['broadcast-runtime', 'runtime-options:changed']);
|
||||
});
|
||||
|
||||
test('send to active overlay window main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const deps = createBuildSendToActiveOverlayWindowMainDepsHandler({
|
||||
sendToActiveOverlayWindowRuntime: () => {
|
||||
calls.push('send');
|
||||
return true;
|
||||
},
|
||||
})();
|
||||
|
||||
assert.equal(deps.sendToActiveOverlayWindowRuntime('x'), true);
|
||||
assert.deepEqual(calls, ['send']);
|
||||
});
|
||||
|
||||
test('set overlay debug visualization main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const deps = createBuildSetOverlayDebugVisualizationEnabledMainDepsHandler({
|
||||
setOverlayDebugVisualizationEnabledRuntime: () => calls.push('set-runtime'),
|
||||
getCurrentEnabled: () => false,
|
||||
setCurrentEnabled: () => calls.push('set-current'),
|
||||
broadcastToOverlayWindows: () => calls.push('broadcast'),
|
||||
})();
|
||||
|
||||
deps.setOverlayDebugVisualizationEnabledRuntime(false, true, () => {}, () => {});
|
||||
assert.equal(deps.getCurrentEnabled(), false);
|
||||
deps.setCurrentEnabled(true);
|
||||
deps.broadcastToOverlayWindows('overlay:debug');
|
||||
assert.deepEqual(calls, ['set-runtime', 'set-current', 'broadcast']);
|
||||
});
|
||||
|
||||
test('open runtime options palette main deps builder maps callbacks', () => {
|
||||
const calls: string[] = [];
|
||||
const deps = createBuildOpenRuntimeOptionsPaletteMainDepsHandler({
|
||||
openRuntimeOptionsPaletteRuntime: () => calls.push('open'),
|
||||
})();
|
||||
|
||||
deps.openRuntimeOptionsPaletteRuntime();
|
||||
assert.deepEqual(calls, ['open']);
|
||||
});
|
||||
Reference in New Issue
Block a user