mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-26 04:19:27 -07:00
fix(config): validate null hover background
This commit is contained in:
@@ -453,6 +453,30 @@ test('parses subtitleStyle.hoverBackground as a hoverTokenBackgroundColor alias'
|
||||
assert.equal(validService.getConfig().subtitleStyle.hoverTokenBackgroundColor, 'transparent');
|
||||
});
|
||||
|
||||
test('parses subtitleStyle.hoverTokenBackgroundColor null as invalid instead of missing', () => {
|
||||
const invalidDir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
path.join(invalidDir, 'config.jsonc'),
|
||||
`{
|
||||
"subtitleStyle": {
|
||||
"hoverTokenBackgroundColor": null
|
||||
}
|
||||
}`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const invalidService = new ConfigService(invalidDir);
|
||||
assert.equal(
|
||||
invalidService.getConfig().subtitleStyle.hoverTokenBackgroundColor,
|
||||
DEFAULT_CONFIG.subtitleStyle.hoverTokenBackgroundColor,
|
||||
);
|
||||
assert.ok(
|
||||
invalidService
|
||||
.getWarnings()
|
||||
.some((warning) => warning.path === 'subtitleStyle.hoverTokenBackgroundColor'),
|
||||
);
|
||||
});
|
||||
|
||||
test('parses subtitleStyle.nameMatchEnabled and warns on invalid values', () => {
|
||||
const validDir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
|
||||
@@ -265,7 +265,9 @@ export function applySubtitleDomainConfig(context: ResolveContext): void {
|
||||
hoverTokenBackgroundColor?: unknown;
|
||||
};
|
||||
const rawHoverTokenBackgroundColor =
|
||||
subtitleStyleSource.hoverTokenBackgroundColor ?? subtitleStyleSource.hoverBackground;
|
||||
subtitleStyleSource.hoverTokenBackgroundColor !== undefined
|
||||
? subtitleStyleSource.hoverTokenBackgroundColor
|
||||
: subtitleStyleSource.hoverBackground;
|
||||
const hoverTokenBackgroundColor = asString(rawHoverTokenBackgroundColor);
|
||||
if (hoverTokenBackgroundColor !== undefined) {
|
||||
resolved.subtitleStyle.hoverTokenBackgroundColor = hoverTokenBackgroundColor;
|
||||
|
||||
Reference in New Issue
Block a user