2024-12-16 09:30:40 -03:00
|
|
|
import { removeDefaultProperty } from "./llmExtract";
|
|
|
|
|
|
|
|
|
|
describe("removeDefaultProperty", () => {
|
2025-01-10 18:35:10 -03:00
|
|
|
it("should remove the default property from a simple object", () => {
|
|
|
|
|
const input = { default: "test", test: "test" };
|
|
|
|
|
const expectedOutput = { test: "test" };
|
|
|
|
|
expect(removeDefaultProperty(input)).toEqual(expectedOutput);
|
|
|
|
|
});
|
2024-12-16 09:30:40 -03:00
|
|
|
|
2025-01-10 18:35:10 -03:00
|
|
|
it("should remove the default property from a nested object", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
default: "test",
|
|
|
|
|
nested: { default: "nestedTest", test: "nestedTest" },
|
|
|
|
|
};
|
|
|
|
|
const expectedOutput = { nested: { test: "nestedTest" } };
|
|
|
|
|
expect(removeDefaultProperty(input)).toEqual(expectedOutput);
|
|
|
|
|
});
|
2024-12-16 09:30:40 -03:00
|
|
|
|
2025-01-10 18:35:10 -03:00
|
|
|
it("should remove the default property from an array of objects", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
array: [
|
|
|
|
|
{ default: "test1", test: "test1" },
|
|
|
|
|
{ default: "test2", test: "test2" },
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const expectedOutput = { array: [{ test: "test1" }, { test: "test2" }] };
|
|
|
|
|
expect(removeDefaultProperty(input)).toEqual(expectedOutput);
|
|
|
|
|
});
|
2024-12-16 09:30:40 -03:00
|
|
|
|
2025-01-10 18:35:10 -03:00
|
|
|
it("should handle objects without a default property", () => {
|
|
|
|
|
const input = { test: "test" };
|
|
|
|
|
const expectedOutput = { test: "test" };
|
|
|
|
|
expect(removeDefaultProperty(input)).toEqual(expectedOutput);
|
|
|
|
|
});
|
2024-12-16 09:30:40 -03:00
|
|
|
|
2025-01-10 18:35:10 -03:00
|
|
|
it("should handle null and non-object inputs", () => {
|
|
|
|
|
expect(removeDefaultProperty(null)).toBeNull();
|
|
|
|
|
expect(removeDefaultProperty("string")).toBe("string");
|
|
|
|
|
expect(removeDefaultProperty(123)).toBe(123);
|
|
|
|
|
});
|
|
|
|
|
});
|