mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { parseLauncherYoutubeSubgenConfig } from './config/youtube-subgen-config.js';
|
|
import { parseLauncherJellyfinConfig } from './config/jellyfin-config.js';
|
|
import { parsePluginRuntimeConfigContent } from './config/plugin-runtime-config.js';
|
|
|
|
test('parseLauncherYoutubeSubgenConfig keeps only valid typed values', () => {
|
|
const parsed = parseLauncherYoutubeSubgenConfig({
|
|
youtubeSubgen: {
|
|
mode: 'preprocess',
|
|
whisperBin: '/usr/bin/whisper',
|
|
whisperModel: '/models/base.bin',
|
|
primarySubLanguages: ['ja', 42, 'en'],
|
|
},
|
|
secondarySub: {
|
|
secondarySubLanguages: ['eng', true, 'deu'],
|
|
},
|
|
jimaku: {
|
|
apiKey: 'abc',
|
|
apiKeyCommand: 'pass show key',
|
|
apiBaseUrl: 'https://jimaku.cc',
|
|
languagePreference: 'ja',
|
|
maxEntryResults: 8.7,
|
|
},
|
|
});
|
|
|
|
assert.equal(parsed.mode, 'preprocess');
|
|
assert.deepEqual(parsed.primarySubLanguages, ['ja', 'en']);
|
|
assert.deepEqual(parsed.secondarySubLanguages, ['eng', 'deu']);
|
|
assert.equal(parsed.jimakuLanguagePreference, 'ja');
|
|
assert.equal(parsed.jimakuMaxEntryResults, 8);
|
|
});
|
|
|
|
test('parseLauncherJellyfinConfig omits legacy token and user id fields', () => {
|
|
const parsed = parseLauncherJellyfinConfig({
|
|
jellyfin: {
|
|
enabled: true,
|
|
serverUrl: 'https://jf.example',
|
|
username: 'alice',
|
|
accessToken: 'legacy-token',
|
|
userId: 'legacy-user',
|
|
pullPictures: true,
|
|
},
|
|
});
|
|
|
|
assert.equal(parsed.enabled, true);
|
|
assert.equal(parsed.serverUrl, 'https://jf.example');
|
|
assert.equal(parsed.username, 'alice');
|
|
assert.equal(parsed.pullPictures, true);
|
|
assert.equal('accessToken' in parsed, false);
|
|
assert.equal('userId' in parsed, false);
|
|
});
|
|
|
|
test('parsePluginRuntimeConfigContent reads socket_path and ignores inline comments', () => {
|
|
const parsed = parsePluginRuntimeConfigContent(`
|
|
# comment
|
|
socket_path = /tmp/custom.sock # trailing comment
|
|
`);
|
|
assert.equal(parsed.socketPath, '/tmp/custom.sock');
|
|
});
|