Anki maturity-based known-word highlighting (#172)

This commit is contained in:
2026-07-27 23:58:02 -07:00
committed by GitHub
parent 08c6807cb1
commit 987b325edb
54 changed files with 3046 additions and 381 deletions
+51
View File
@@ -328,3 +328,54 @@ test('warns and falls back for invalid proxy settings', () => {
assert.ok(warnings.some((warning) => warning.path === 'ankiConnect.proxy.port'));
assert.ok(warnings.some((warning) => warning.path === 'ankiConnect.proxy.upstreamUrl'));
});
test('resolves knownWords maturity settings from config', () => {
const { context, warnings } = makeContext({
knownWords: { highlightEnabled: true, maturityEnabled: true, matureThresholdDays: 30 },
});
applyAnkiConnectResolution(context);
assert.equal(context.resolved.ankiConnect.knownWords.maturityEnabled, true);
assert.equal(context.resolved.ankiConnect.knownWords.matureThresholdDays, 30);
assert.deepEqual(warnings, []);
});
test('warns and falls back for invalid knownWords maturity settings', () => {
const { context, warnings } = makeContext({
knownWords: { maturityEnabled: 'yes', matureThresholdDays: 0 },
});
applyAnkiConnectResolution(context);
assert.equal(
context.resolved.ankiConnect.knownWords.maturityEnabled,
DEFAULT_CONFIG.ankiConnect.knownWords.maturityEnabled,
);
assert.equal(
context.resolved.ankiConnect.knownWords.matureThresholdDays,
DEFAULT_CONFIG.ankiConnect.knownWords.matureThresholdDays,
);
assert.ok(warnings.some((warning) => warning.path === 'ankiConnect.knownWords.maturityEnabled'));
assert.ok(
warnings.some((warning) => warning.path === 'ankiConnect.knownWords.matureThresholdDays'),
);
});
test('omitted knownWords maturity settings fall back to defaults', () => {
const { context, warnings } = makeContext({
knownWords: { highlightEnabled: true },
});
applyAnkiConnectResolution(context);
assert.equal(
context.resolved.ankiConnect.knownWords.maturityEnabled,
DEFAULT_CONFIG.ankiConnect.knownWords.maturityEnabled,
);
assert.equal(
context.resolved.ankiConnect.knownWords.matureThresholdDays,
DEFAULT_CONFIG.ankiConnect.knownWords.matureThresholdDays,
);
assert.deepEqual(warnings, []);
});