mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-07 13:08:54 -07:00
feat(config): add configuration window (#70)
This commit is contained in:
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import { DEFAULT_CONFIG } from './config';
|
||||
import { RuntimeOptionsManager } from './runtime-options';
|
||||
|
||||
test('SM-012 runtime options path does not use JSON serialize-clone helpers', () => {
|
||||
@@ -59,3 +60,25 @@ test('RuntimeOptionsManager returns detached effective Anki config copies', () =
|
||||
assert.deepEqual(baseConfig.tags, ['SubMiner']);
|
||||
assert.equal(baseConfig.behavior.autoUpdateNewCards, true);
|
||||
});
|
||||
|
||||
test('RuntimeOptionsManager keeps known-word and n+1 annotation toggles separate', () => {
|
||||
const baseConfig = structuredClone(DEFAULT_CONFIG.ankiConnect);
|
||||
const patches: unknown[] = [];
|
||||
const manager = new RuntimeOptionsManager(() => structuredClone(baseConfig), {
|
||||
applyAnkiPatch: (patch) => {
|
||||
patches.push(patch);
|
||||
},
|
||||
onOptionsChanged: () => undefined,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
manager.setOptionValue('subtitle.annotation.knownWords.highlightEnabled', true).ok,
|
||||
true,
|
||||
);
|
||||
assert.equal(manager.setOptionValue('subtitle.annotation.nPlusOne', true).ok, true);
|
||||
|
||||
const effective = manager.getEffectiveAnkiConnectConfig();
|
||||
assert.equal(effective.knownWords?.highlightEnabled, true);
|
||||
assert.equal(effective.nPlusOne?.enabled, true);
|
||||
assert.deepEqual(patches, []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user