2025-05-31 18:41:00 +00:00
|
|
|
import { describe, expect, test } from "bun:test"
|
|
|
|
|
import { App } from "../../src/app/app"
|
2025-05-31 21:12:16 +00:00
|
|
|
import { GlobTool } from "../../src/tool/glob"
|
2025-06-01 18:46:04 +00:00
|
|
|
import { ListTool } from "../../src/tool/ls"
|
2025-05-21 14:30:39 +00:00
|
|
|
|
|
|
|
|
describe("tool.glob", () => {
|
|
|
|
|
test("truncate", async () => {
|
2025-06-01 18:46:04 +00:00
|
|
|
await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
|
2025-06-03 15:59:03 +00:00
|
|
|
let result = await GlobTool.execute(
|
|
|
|
|
{ pattern: "./node_modules/**/*" },
|
|
|
|
|
{ sessionID: "test" },
|
|
|
|
|
)
|
2025-05-31 18:41:00 +00:00
|
|
|
expect(result.metadata.truncated).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
})
|
2025-05-21 14:30:39 +00:00
|
|
|
test("basic", async () => {
|
2025-06-01 18:46:04 +00:00
|
|
|
await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
|
2025-06-03 15:59:03 +00:00
|
|
|
let result = await GlobTool.execute(
|
|
|
|
|
{ pattern: "*.json" },
|
|
|
|
|
{ sessionID: "test" },
|
|
|
|
|
)
|
2025-05-21 14:30:39 +00:00
|
|
|
expect(result.metadata).toMatchObject({
|
|
|
|
|
truncated: false,
|
2025-05-26 18:18:07 +00:00
|
|
|
count: 2,
|
2025-05-31 18:41:00 +00:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
2025-05-26 18:09:17 +00:00
|
|
|
|
|
|
|
|
describe("tool.ls", () => {
|
|
|
|
|
test("basic", async () => {
|
2025-06-01 19:01:57 +00:00
|
|
|
const result = await App.provide(
|
|
|
|
|
{ cwd: process.cwd(), version: "test" },
|
|
|
|
|
async () => {
|
2025-06-03 15:59:03 +00:00
|
|
|
return await ListTool.execute(
|
|
|
|
|
{ path: "./example" },
|
|
|
|
|
{ sessionID: "test" },
|
|
|
|
|
)
|
2025-06-01 19:01:57 +00:00
|
|
|
},
|
|
|
|
|
)
|
2025-05-31 18:41:00 +00:00
|
|
|
expect(result.output).toMatchSnapshot()
|
|
|
|
|
})
|
|
|
|
|
})
|