refactor(config): dedupe native command setting resolver

This commit is contained in:
Peter Steinberger
2026-02-18 23:08:52 +00:00
parent 8b257703d8
commit f33ecae0bb
2 changed files with 61 additions and 11 deletions

View File

@@ -1,5 +1,9 @@
import { describe, expect, it } from "vitest";
import { resolveNativeSkillsEnabled } from "./commands.js";
import {
isNativeCommandsExplicitlyDisabled,
resolveNativeCommandsEnabled,
resolveNativeSkillsEnabled,
} from "./commands.js";
describe("resolveNativeSkillsEnabled", () => {
it("uses provider defaults for auto", () => {
@@ -46,3 +50,50 @@ describe("resolveNativeSkillsEnabled", () => {
).toBe(false);
});
});
describe("resolveNativeCommandsEnabled", () => {
it("follows the same provider default heuristic", () => {
expect(resolveNativeCommandsEnabled({ providerId: "discord", globalSetting: "auto" })).toBe(
true,
);
expect(resolveNativeCommandsEnabled({ providerId: "telegram", globalSetting: "auto" })).toBe(
true,
);
expect(resolveNativeCommandsEnabled({ providerId: "slack", globalSetting: "auto" })).toBe(
false,
);
});
it("honors explicit provider/global booleans", () => {
expect(
resolveNativeCommandsEnabled({
providerId: "slack",
providerSetting: true,
globalSetting: false,
}),
).toBe(true);
expect(
resolveNativeCommandsEnabled({
providerId: "discord",
globalSetting: false,
}),
).toBe(false);
});
});
describe("isNativeCommandsExplicitlyDisabled", () => {
it("returns true only for explicit false at provider or fallback global", () => {
expect(
isNativeCommandsExplicitlyDisabled({ providerSetting: false, globalSetting: true }),
).toBe(true);
expect(
isNativeCommandsExplicitlyDisabled({ providerSetting: undefined, globalSetting: false }),
).toBe(true);
expect(
isNativeCommandsExplicitlyDisabled({ providerSetting: true, globalSetting: false }),
).toBe(false);
expect(
isNativeCommandsExplicitlyDisabled({ providerSetting: "auto", globalSetting: false }),
).toBe(false);
});
});