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 / git / probes / kind-walk-of.test.ts
43 lines · 1.1 KBRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Git from '../../../hooks/git'
4import Fixtures from '../../fixtures'
5
6tier('builtin')
7
8describe('kind-walk-of', () => {
9 const DEEP_PATH = Array.from({ length: Fixtures.WALK_DEPTH }, () => 'a').join(
10 '/',
11 )
12
13 function walkOf(budget: number) {
14 const listed: string[] = []
15
16 const walk = Git.kindWalkOf(
17 directory => {
18 listed.push(directory)
19
20 return Promise.resolve(new Map([['a', 'dir' as const]]))
21 },
22 '/repo',
23 budget,
24 )
25
26 return { walk, listed }
27 }
28
29 test('a fifty-thousand-deep path reads over-budget in budget', async () => {
30 const { walk, listed } = walkOf(Fixtures.WALK_BUDGET)
31
32 expect(await walk.kindOf(DEEP_PATH)).toBe('over-budget')
33 expect(listed.length).toBe(Fixtures.WALK_BUDGET)
34 })
35
36 test('a path within the budget reads its kind from its parent', async () => {
37 const { walk, listed } = walkOf(Fixtures.WALK_BUDGET)
38
39 expect(await walk.kindOf('a/a/a')).toBe('dir')
40 expect(await walk.kindOf('a/a/b')).toBe(null)
41 expect(listed).toEqual(['/repo', '/repo/a', '/repo/a/a'])
42 })
43})