mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 15:42:53 +00:00
23 lines
839 B
TypeScript
23 lines
839 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { parseConfigJson5 } from "./config.js";
|
|
|
|
describe("parseConfigJson5", () => {
|
|
it("uses native JSON parsing before JSON5 fallback", () => {
|
|
const json5 = { parse: vi.fn(() => ({ fromJson5: true })) };
|
|
|
|
const result = parseConfigJson5('{"gateway":{"mode":"local"}}', json5);
|
|
|
|
expect(result).toEqual({ ok: true, parsed: { gateway: { mode: "local" } } });
|
|
expect(json5.parse).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("falls back to JSON5 for authored config syntax", () => {
|
|
const json5 = { parse: vi.fn(() => ({ gateway: { mode: "local" } })) };
|
|
|
|
const result = parseConfigJson5("{ gateway: { mode: 'local' } }", json5);
|
|
|
|
expect(result).toEqual({ ok: true, parsed: { gateway: { mode: "local" } } });
|
|
expect(json5.parse).toHaveBeenCalledOnce();
|
|
});
|
|
});
|