tool.test.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. })
  11. expect(result.metadata.truncated).toBe(true)
  12. })
  13. })
  14. test("basic", async () => {
  15. await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
  16. let result = await GlobTool.execute({
  17. pattern: "*.json",
  18. })
  19. expect(result.metadata).toMatchObject({
  20. truncated: false,
  21. count: 2,
  22. })
  23. })
  24. })
  25. })
  26. describe("tool.ls", () => {
  27. test("basic", async () => {
  28. const result = await App.provide({ cwd: process.cwd(), version: "test" }, async () => {
  29. return await ListTool.execute({
  30. path: "./example",
  31. })
  32. })
  33. expect(result.output).toMatchSnapshot()
  34. })
  35. })