-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #955 from mendableai/rafa/fix-default-on-schema-ll…
…m-extract fixed optional+default bug on llm schema
- Loading branch information
Showing
3 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/api/src/scraper/scrapeURL/transformers/llmExtract.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { removeDefaultProperty } from "./llmExtract"; | ||
|
||
describe("removeDefaultProperty", () => { | ||
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); | ||
}); | ||
|
||
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); | ||
}); | ||
|
||
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); | ||
}); | ||
|
||
it("should handle objects without a default property", () => { | ||
const input = { test: "test" }; | ||
const expectedOutput = { test: "test" }; | ||
expect(removeDefaultProperty(input)).toEqual(expectedOutput); | ||
}); | ||
|
||
it("should handle null and non-object inputs", () => { | ||
expect(removeDefaultProperty(null)).toBeNull(); | ||
expect(removeDefaultProperty("string")).toBe("string"); | ||
expect(removeDefaultProperty(123)).toBe(123); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters