Skip to content

Commit

Permalink
chore: add tests for parsing empty files and strings
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Aug 13, 2024
1 parent 1be0bce commit cdca82b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Empty file added tests/fixtures/empty.gpt
Empty file.
12 changes: 12 additions & 0 deletions tests/gptscript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ describe("gptscript module", () => {
expect((response[0] as gptscript.Tool).instructions).toEqual("who was the president in 1928?")
}, 30000)

test("parse empty file", async () => {
const response = await g.parse(path.join(__dirname, "fixtures", "empty.gpt"))
expect(response).toBeDefined()
expect(response).toHaveLength(0)
}, 30000)

test("parse file with metadata", async () => {
const response = await g.parse(path.join(__dirname, "fixtures", "parse-with-metadata.gpt"))
expect(response).toBeDefined()
Expand All @@ -258,6 +264,12 @@ describe("gptscript module", () => {
expect((response[0] as gptscript.Tool).instructions).toEqual(tool)
}, 30000)

test("parse empty string tool", async () => {
const response = await g.parseTool("")
expect(response).toBeDefined()
expect(response).toHaveLength(0)
}, 30000)

test("parse string tool with text node", async () => {
const tool = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?\n---\n!markdown\nThis is a text node"
const response = await g.parseTool(tool)
Expand Down

0 comments on commit cdca82b

Please sign in to comment.