mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 06:22:44 -08:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
65
src/main/runtime/startup-warmups-main-deps.test.ts
Normal file
65
src/main/runtime/startup-warmups-main-deps.test.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
createBuildLaunchBackgroundWarmupTaskMainDepsHandler,
|
||||
createBuildStartBackgroundWarmupsMainDepsHandler,
|
||||
} from './startup-warmups-main-deps';
|
||||
|
||||
test('startup warmups main deps builders map callbacks', async () => {
|
||||
const calls: string[] = [];
|
||||
|
||||
const launch = createBuildLaunchBackgroundWarmupTaskMainDepsHandler({
|
||||
now: () => 11,
|
||||
logDebug: (message) => calls.push(`debug:${message}`),
|
||||
logWarn: (message) => calls.push(`warn:${message}`),
|
||||
})();
|
||||
assert.equal(launch.now(), 11);
|
||||
launch.logDebug('x');
|
||||
launch.logWarn('y');
|
||||
|
||||
const start = createBuildStartBackgroundWarmupsMainDepsHandler({
|
||||
getStarted: () => false,
|
||||
setStarted: (started) => calls.push(`started:${started}`),
|
||||
isTexthookerOnlyMode: () => false,
|
||||
launchTask: (label, task) => {
|
||||
calls.push(`launch:${label}`);
|
||||
void task();
|
||||
},
|
||||
createMecabTokenizerAndCheck: async () => {
|
||||
calls.push('mecab');
|
||||
},
|
||||
ensureYomitanExtensionLoaded: async () => {
|
||||
calls.push('yomitan');
|
||||
},
|
||||
prewarmSubtitleDictionaries: async () => {
|
||||
calls.push('dict');
|
||||
},
|
||||
shouldAutoConnectJellyfinRemote: () => true,
|
||||
startJellyfinRemoteSession: async () => {
|
||||
calls.push('jellyfin');
|
||||
},
|
||||
})();
|
||||
assert.equal(start.getStarted(), false);
|
||||
start.setStarted(true);
|
||||
assert.equal(start.isTexthookerOnlyMode(), false);
|
||||
start.launchTask('demo', async () => {
|
||||
calls.push('task');
|
||||
});
|
||||
await start.createMecabTokenizerAndCheck();
|
||||
await start.ensureYomitanExtensionLoaded();
|
||||
await start.prewarmSubtitleDictionaries();
|
||||
assert.equal(start.shouldAutoConnectJellyfinRemote(), true);
|
||||
await start.startJellyfinRemoteSession();
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
'debug:x',
|
||||
'warn:y',
|
||||
'started:true',
|
||||
'launch:demo',
|
||||
'task',
|
||||
'mecab',
|
||||
'yomitan',
|
||||
'dict',
|
||||
'jellyfin',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user