mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ivan Melck <ivan@spec-kitty.ai>
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { resolveConfig } from '../resolve';
|
|
|
|
test('resolveConfig trims configured mpv executable path', () => {
|
|
const { resolved, warnings } = resolveConfig({
|
|
mpv: {
|
|
executablePath: ' C:\\Program Files\\mpv\\mpv.exe ',
|
|
},
|
|
});
|
|
|
|
assert.equal(resolved.mpv.executablePath, 'C:\\Program Files\\mpv\\mpv.exe');
|
|
assert.deepEqual(warnings, []);
|
|
});
|
|
|
|
test('resolveConfig parses configured mpv launch mode', () => {
|
|
const { resolved, warnings } = resolveConfig({
|
|
mpv: {
|
|
launchMode: 'maximized',
|
|
},
|
|
});
|
|
|
|
assert.equal(resolved.mpv.launchMode, 'maximized');
|
|
assert.deepEqual(warnings, []);
|
|
});
|
|
|
|
test('resolveConfig warns for invalid mpv executable path type', () => {
|
|
const { resolved, warnings } = resolveConfig({
|
|
mpv: {
|
|
executablePath: 42 as never,
|
|
},
|
|
});
|
|
|
|
assert.equal(resolved.mpv.executablePath, '');
|
|
assert.equal(warnings.length, 1);
|
|
assert.deepEqual(warnings[0], {
|
|
path: 'mpv.executablePath',
|
|
value: 42,
|
|
fallback: '',
|
|
message: 'Expected string.',
|
|
});
|
|
});
|
|
|
|
test('resolveConfig warns for invalid mpv launch mode', () => {
|
|
const { resolved, warnings } = resolveConfig({
|
|
mpv: {
|
|
launchMode: 'cinema' as never,
|
|
},
|
|
});
|
|
|
|
assert.equal(resolved.mpv.launchMode, 'normal');
|
|
assert.equal(warnings.length, 1);
|
|
assert.deepEqual(warnings[0], {
|
|
path: 'mpv.launchMode',
|
|
value: 'cinema',
|
|
fallback: 'normal',
|
|
message: "Expected one of: 'normal', 'maximized', 'fullscreen'.",
|
|
});
|
|
});
|
|
|
|
test('resolveConfig parses the Jimaku auto-open toggle and warns on non-boolean values', () => {
|
|
const enabled = resolveConfig({ jimaku: { autoOpenWhenPrimarySubtitleMissing: true } });
|
|
assert.equal(enabled.resolved.jimaku.autoOpenWhenPrimarySubtitleMissing, true);
|
|
assert.deepEqual(enabled.warnings, []);
|
|
|
|
const invalid = resolveConfig({
|
|
jimaku: { autoOpenWhenPrimarySubtitleMissing: 'sometimes' as never },
|
|
});
|
|
assert.equal(invalid.resolved.jimaku.autoOpenWhenPrimarySubtitleMissing, false);
|
|
assert.deepEqual(
|
|
invalid.warnings.map((warning) => warning.path),
|
|
['jimaku.autoOpenWhenPrimarySubtitleMissing'],
|
|
);
|
|
});
|