mirror of
https://github.com/millionco/react-doctor.git
synced 2026-09-14 20:00:24 +08:00
9777f1ac45
Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
991 B
TypeScript
42 lines
991 B
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
import { serializeTsObjectLiteral } from "../src/cli/utils/serialize-ts-object-literal.js";
|
|
|
|
describe("serializeTsObjectLiteral", () => {
|
|
it("leaves identifier keys unquoted and quotes the rest", () => {
|
|
expect(
|
|
serializeTsObjectLiteral({
|
|
lint: true,
|
|
rules: { "react-doctor/no-danger": "off", noDanger: "warn" },
|
|
}),
|
|
).toBe(
|
|
`{
|
|
lint: true,
|
|
rules: {
|
|
"react-doctor/no-danger": "off",
|
|
noDanger: "warn"
|
|
}
|
|
}`,
|
|
);
|
|
});
|
|
|
|
it("serializes arrays and empty containers", () => {
|
|
expect(serializeTsObjectLiteral({ ignore: { tags: ["design", "test-noise"] }, extra: {} }))
|
|
.toBe(`{
|
|
ignore: {
|
|
tags: [
|
|
"design",
|
|
"test-noise"
|
|
]
|
|
},
|
|
extra: {}
|
|
}`);
|
|
expect(serializeTsObjectLiteral([])).toBe("[]");
|
|
});
|
|
|
|
it("escapes string values via JSON", () => {
|
|
expect(serializeTsObjectLiteral({ rootDir: 'a"b' })).toBe(`{
|
|
rootDir: "a\\"b"
|
|
}`);
|
|
});
|
|
});
|