Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

toolActivity.test.ts

57 lines1.4 KB

1import { describe, expect, it } from "vitest";
2​
3import { deriveToolActivityPresentation } from "./toolActivity.ts";
4​
5describe("toolActivity", () => {
6 it("normalizes command tools to a stable ran-command label", () => {
7 expect(
8 deriveToolActivityPresentation({
9 itemType: "command_execution",
10 title: "Terminal",
11 detail: "Terminal",
12 data: {
13 command: "bun run lint",
14 },
15 fallbackSummary: "Terminal",
16 }),
17 ).toEqual({
18 summary: "Ran command",
19 detail: "bun run lint",
20 });
21 });
22​
23 it("uses structured file paths for read-file tools when available", () => {
24 expect(
25 deriveToolActivityPresentation({
26 itemType: "dynamic_tool_call",
27 title: "Read File",
28 detail: "Read File",
29 data: {
30 kind: "read",
31 locations: [{ path: "/tmp/app.ts" }],
32 },
33 fallbackSummary: "Read File",
34 }),
35 ).toEqual({
36 summary: "Read file",
37 detail: "/tmp/app.ts",
38 });
39 });
40​
41 it("drops duplicated generic read-file detail when no path is available", () => {
42 expect(
43 deriveToolActivityPresentation({
44 itemType: "dynamic_tool_call",
45 title: "Read File",
46 detail: "Read File",
47 data: {
48 kind: "read",
49 rawInput: {},
50 },
51 fallbackSummary: "Read File",
52 }),
53 ).toEqual({
54 summary: "Read file",
55 });
56 });
57});