tool.test.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { describe, expect, test } from "bun:test"
  2. import { App } from "../../src/app/app"
  3. import { GlobTool } from "../../src/tool/glob"
  4. import { ListTool } from "../../src/tool/ls"
  5. describe("tool.glob", () => {
  6. test("truncate", async () => {
  7. await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
  8. let result = await GlobTool.execute(
  9. { pattern: "./node_modules/**/*" },
  10. { sessionID: "test" },
  11. )
  12. expect(result.metadata.truncated).toBe(true)
  13. })
  14. })
  15. test("basic", async () => {
  16. await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
  17. let result = await GlobTool.execute(
  18. { pattern: "*.json" },
  19. { sessionID: "test" },
  20. )
  21. expect(result.metadata).toMatchObject({
  22. truncated: false,
  23. count: 2,
  24. })
  25. })
  26. })
  27. })
  28. describe("tool.ls", () => {
  29. test("basic", async () => {
  30. const result = await App.provide(
  31. { cwd: process.cwd(), version: "test" },
  32. async () => {
  33. return await ListTool.execute(
  34. { path: "./example" },
  35. { sessionID: "test" },
  36. )
  37. },
  38. )
  39. expect(result.output).toMatchSnapshot()
  40. })
  41. })