import { expect, test } from "vitest";
import { normalizeJsonObjectString } from "@/shared/ui/JsonEditorField.jsx";

test("normalizes valid json object strings", () => {
    expect(normalizeJsonObjectString(`{"app_id":307715}`)).toBe(`{"app_id":307715}`);
    expect(normalizeJsonObjectString("")).toBe("{}");
});

test("rejects invalid json and non-object json", () => {
    expect(() => normalizeJsonObjectString("{")).toThrow("JSON 格式错误");
    expect(() => normalizeJsonObjectString("[]")).toThrow("配置 JSON 必须是对象");
});
