mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 00:11:27 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
76
src/main/runtime/tray-main-actions.test.ts
Normal file
76
src/main/runtime/tray-main-actions.test.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
createBuildTrayMenuTemplateHandler,
|
||||
createResolveTrayIconPathHandler,
|
||||
} from './tray-main-actions';
|
||||
|
||||
test('resolve tray icon path handler forwards runtime dependencies', () => {
|
||||
const calls: string[] = [];
|
||||
const resolveTrayIconPath = createResolveTrayIconPathHandler({
|
||||
resolveTrayIconPathRuntime: (options) => {
|
||||
calls.push(`platform:${options.platform}`);
|
||||
calls.push(`resources:${options.resourcesPath}`);
|
||||
calls.push(`app:${options.appPath}`);
|
||||
calls.push(`dir:${options.dirname}`);
|
||||
calls.push(`join:${options.joinPath('a', 'b')}`);
|
||||
calls.push(`exists:${options.fileExists('/tmp/icon.png')}`);
|
||||
return '/tmp/icon.png';
|
||||
},
|
||||
platform: 'darwin',
|
||||
resourcesPath: '/resources',
|
||||
appPath: '/app',
|
||||
dirname: '/dir',
|
||||
joinPath: (...parts) => parts.join('/'),
|
||||
fileExists: () => true,
|
||||
});
|
||||
|
||||
assert.equal(resolveTrayIconPath(), '/tmp/icon.png');
|
||||
assert.deepEqual(calls, [
|
||||
'platform:darwin',
|
||||
'resources:/resources',
|
||||
'app:/app',
|
||||
'dir:/dir',
|
||||
'join:a/b',
|
||||
'exists:true',
|
||||
]);
|
||||
});
|
||||
|
||||
test('build tray template handler wires actions and init guards', () => {
|
||||
const calls: string[] = [];
|
||||
let initialized = false;
|
||||
const buildTemplate = createBuildTrayMenuTemplateHandler({
|
||||
buildTrayMenuTemplateRuntime: (handlers) => {
|
||||
handlers.openOverlay();
|
||||
handlers.openYomitanSettings();
|
||||
handlers.openRuntimeOptions();
|
||||
handlers.openJellyfinSetup();
|
||||
handlers.openAnilistSetup();
|
||||
handlers.quitApp();
|
||||
return [{ label: 'ok' }] as never;
|
||||
},
|
||||
initializeOverlayRuntime: () => {
|
||||
initialized = true;
|
||||
calls.push('init');
|
||||
},
|
||||
isOverlayRuntimeInitialized: () => initialized,
|
||||
setVisibleOverlayVisible: (visible) => calls.push(`visible:${visible}`),
|
||||
openYomitanSettings: () => calls.push('yomitan'),
|
||||
openRuntimeOptionsPalette: () => calls.push('runtime-options'),
|
||||
openJellyfinSetupWindow: () => calls.push('jellyfin'),
|
||||
openAnilistSetupWindow: () => calls.push('anilist'),
|
||||
quitApp: () => calls.push('quit'),
|
||||
});
|
||||
|
||||
const template = buildTemplate();
|
||||
assert.deepEqual(template, [{ label: 'ok' }]);
|
||||
assert.deepEqual(calls, [
|
||||
'init',
|
||||
'visible:true',
|
||||
'yomitan',
|
||||
'runtime-options',
|
||||
'jellyfin',
|
||||
'anilist',
|
||||
'quit',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user