mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 18:22:42 -08:00
refactor: extract runtime options manager initializer
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createRuntimeOptionsManagerRuntimeService } from "./runtime-options-manager-runtime-service";
|
||||
|
||||
test("createRuntimeOptionsManagerRuntimeService wires patch + options changed callbacks", () => {
|
||||
const patches: unknown[] = [];
|
||||
const changedSnapshots: unknown[] = [];
|
||||
const manager = createRuntimeOptionsManagerRuntimeService({
|
||||
getAnkiConfig: () => ({
|
||||
behavior: { autoUpdateNewCards: true },
|
||||
isKiku: { fieldGrouping: "manual" },
|
||||
}),
|
||||
applyAnkiPatch: (patch) => {
|
||||
patches.push(patch);
|
||||
},
|
||||
onOptionsChanged: (options) => {
|
||||
changedSnapshots.push(options);
|
||||
},
|
||||
});
|
||||
|
||||
const result = manager.setOptionValue("anki.autoUpdateNewCards", false);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(patches.length > 0, true);
|
||||
assert.equal(changedSnapshots.length > 0, true);
|
||||
});
|
||||
Reference in New Issue
Block a user