mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-08-27 05:47:07 +00:00
Reorganise settings around common tasks
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
type SettingSpec,
|
||||
} from "./SettingSpec.ts";
|
||||
import { createAdvancedSettingSpecGroups } from "./AdvancedSettingSpecs.ts";
|
||||
import { createExtraMenuSettingSpecGroup, createGeneralSettingSpecGroups } from "./GeneralSettingSpecs.ts";
|
||||
|
||||
const rangeMessages = {
|
||||
valueShouldBeInRange: ({ min, max }: { min?: number; max?: number }) => `${min ?? "~"}..${max ?? "~"}`,
|
||||
@@ -74,6 +75,52 @@ describe("Advanced setting specifications", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("General setting specifications", () => {
|
||||
it("shares every General and Logging control between the imperative and declarative renderers", () => {
|
||||
const groups = createGeneralSettingSpecGroups({
|
||||
showEditorStatusDetails: () => true,
|
||||
showVerboseLog: () => true,
|
||||
});
|
||||
|
||||
expect(groups.map(({ heading }) => heading)).toEqual(["Appearance", "Logging"]);
|
||||
expect(groups.flatMap(({ items }) => items.map(({ key }) => key))).toEqual([
|
||||
"displayLanguage",
|
||||
"showStatusOnEditor",
|
||||
"showOnlyIconsOnEditor",
|
||||
"showStatusOnStatusbar",
|
||||
"hideFileWarningNotice",
|
||||
"networkWarningStyle",
|
||||
"lessInformationInLog",
|
||||
"showVerboseLog",
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps the three feature-level controls together under Extra menus", () => {
|
||||
const group = createExtraMenuSettingSpecGroup();
|
||||
|
||||
expect(group.heading).toBe("Extra menus");
|
||||
expect(group.items.map(({ key }) => key)).toEqual(["useAdvancedMode", "usePowerUserMode", "useEdgeCaseMode"]);
|
||||
});
|
||||
|
||||
it("retains the two conditional visibility rules", () => {
|
||||
let editorDetails = false;
|
||||
let verboseLog = false;
|
||||
const specs = createGeneralSettingSpecGroups({
|
||||
showEditorStatusDetails: () => editorDetails,
|
||||
showVerboseLog: () => verboseLog,
|
||||
}).flatMap(({ items }) => items);
|
||||
const editorIcons = specs.find(({ key }) => key === "showOnlyIconsOnEditor");
|
||||
const verbose = specs.find(({ key }) => key === "showVerboseLog");
|
||||
|
||||
expect(editorIcons?.visible?.()).toBe(false);
|
||||
expect(verbose?.visible?.()).toBe(false);
|
||||
editorDetails = true;
|
||||
verboseLog = true;
|
||||
expect(editorIcons?.visible?.()).toBe(true);
|
||||
expect(verbose?.visible?.()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("SettingSpec conversion", () => {
|
||||
it("maps metadata and a toggle to an Obsidian definition without importing the runtime API", () => {
|
||||
const visible = vi.fn(() => true);
|
||||
|
||||
Reference in New Issue
Block a user