Skip to content

Commit cdca82b

Browse files
committed
chore: add tests for parsing empty files and strings
Signed-off-by: Donnie Adams <[email protected]>
1 parent 1be0bce commit cdca82b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/fixtures/empty.gpt

Whitespace-only changes.

tests/gptscript.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ describe("gptscript module", () => {
241241
expect((response[0] as gptscript.Tool).instructions).toEqual("who was the president in 1928?")
242242
}, 30000)
243243

244+
test("parse empty file", async () => {
245+
const response = await g.parse(path.join(__dirname, "fixtures", "empty.gpt"))
246+
expect(response).toBeDefined()
247+
expect(response).toHaveLength(0)
248+
}, 30000)
249+
244250
test("parse file with metadata", async () => {
245251
const response = await g.parse(path.join(__dirname, "fixtures", "parse-with-metadata.gpt"))
246252
expect(response).toBeDefined()
@@ -258,6 +264,12 @@ describe("gptscript module", () => {
258264
expect((response[0] as gptscript.Tool).instructions).toEqual(tool)
259265
}, 30000)
260266

267+
test("parse empty string tool", async () => {
268+
const response = await g.parseTool("")
269+
expect(response).toBeDefined()
270+
expect(response).toHaveLength(0)
271+
}, 30000)
272+
261273
test("parse string tool with text node", async () => {
262274
const tool = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?\n---\n!markdown\nThis is a text node"
263275
const response = await g.parseTool(tool)

0 commit comments

Comments
 (0)