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 / boot-probe.test.ts
41 lines · 1.1 KBRaw
1import { clock, describe, expect, test, tier } from 'claude-code/testing'
2
3import Limits from '../hooks/limits'
4import Fixtures from './fixtures'
5
6const GIT_HUNG = `git aborted: still running after ${Limits.GIT_TIMEOUT_MS}ms`
7
8tier('builtin')
9
10describe('boot-probe', () => {
11 test('/diff at boot joins the boot probe, then asks again', async ($, on) => {
12 const probes: (readonly string[])[] = []
13 Fixtures.startsSession(on)
14 on('process.run', async ($, e) => {
15 probes.push(e.argv)
16
17 if (probes.length === 1) {
18 await clock.sleep(Limits.GIT_TIMEOUT_MS)
19
20 return { deny: GIT_HUNG }
21 }
22
23 return { value: Fixtures.NOT_A_REPOSITORY }
24 })
25
26 const booting = $.session.start(Fixtures.SESSION)
27 await clock.advance(0)
28 const ran = $.command.run(Fixtures.DIFF)
29 await clock.advance(0)
30
31 expect(probes, 'the boot probe, which /diff joined').toHaveLength(1)
32
33 await clock.advance(Limits.GIT_TIMEOUT_MS)
34 await booting
35
36 expect(await ran).toEqual({
37 text: expect.stringContaining("isn't in a git repository"),
38 })
39 expect(probes, 'then one more of its own').toHaveLength(2)
40 })
41})