feat: add /config chat config updates
This commit is contained in:
28
src/config/config-paths.test.ts
Normal file
28
src/config/config-paths.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
getConfigValueAtPath,
|
||||
parseConfigPath,
|
||||
setConfigValueAtPath,
|
||||
unsetConfigValueAtPath,
|
||||
} from "./config-paths.js";
|
||||
|
||||
describe("config paths", () => {
|
||||
it("rejects empty and blocked paths", () => {
|
||||
expect(parseConfigPath("")).toEqual({
|
||||
ok: false,
|
||||
error: "Invalid path. Use dot notation (e.g. foo.bar).",
|
||||
});
|
||||
expect(parseConfigPath("__proto__.polluted").ok).toBe(false);
|
||||
});
|
||||
|
||||
it("sets, gets, and unsets nested values", () => {
|
||||
const root: Record<string, unknown> = {};
|
||||
const parsed = parseConfigPath("foo.bar");
|
||||
if (!parsed.ok || !parsed.path) throw new Error("path parse failed");
|
||||
setConfigValueAtPath(root, parsed.path, 123);
|
||||
expect(getConfigValueAtPath(root, parsed.path)).toBe(123);
|
||||
expect(unsetConfigValueAtPath(root, parsed.path)).toBe(true);
|
||||
expect(getConfigValueAtPath(root, parsed.path)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user