spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / tests / tools / edited-path-of.test.ts
64 lines · 1.4 KBRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Tools from '../../hooks/tools'
4
5tier('builtin')
6
7describe('edited-path-of', () => {
8 test("each editing tool's own path argument", () => {
9 expect(
10 Tools.editedPathOf({
11 tool: 'Edit',
12 tool_use_id: 'toolu_1',
13 file_path: '/work/app.ts',
14 old_string: '1',
15 new_string: '2',
16 }),
17 ).toBe('/work/app.ts')
18
19 expect(
20 Tools.editedPathOf({
21 tool: 'Write',
22 tool_use_id: 'toolu_2',
23 file_path: 'notes.md',
24 content: '',
25 }),
26 ).toBe('notes.md')
27
28 expect(
29 Tools.editedPathOf({
30 tool: 'NotebookEdit',
31 tool_use_id: 'toolu_3',
32 notebook_path: '/work/plot.ipynb',
33 new_source: '1',
34 }),
35 ).toBe('/work/plot.ipynb')
36 })
37
38 test('an empty path, or a tool that edits no file: null', () => {
39 expect(
40 Tools.editedPathOf({
41 tool: 'Write',
42 tool_use_id: 'toolu_4',
43 file_path: '',
44 content: '',
45 }),
46 ).toBeNull()
47
48 expect(
49 Tools.editedPathOf({
50 tool: 'Bash',
51 tool_use_id: 'toolu_5',
52 command: 'make',
53 }),
54 ).toBeNull()
55
56 expect(
57 Tools.editedPathOf({
58 tool: 'mcp__files__write',
59 tool_use_id: 'toolu_6',
60 file_path: '/work/app.ts',
61 }),
62 ).toBeNull()
63 })
64})