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 / record.test.ts
39 lines · 1.2 KBRaw
1import type { Args } from 'claude-code'
2import { describe, expect, test, tier } from 'claude-code/testing'
3
4import Record from '../hooks/record'
5import Fixtures from './fixtures'
6
7tier('builtin')
8
9describe('record', () => {
10 test('a read marks how its hunks went, by the same names', async ($, on) => {
11 let refusal: string | null = null
12
13 const marked = Fixtures.keeping<Args<'telemetry.mark'>>()
14
15 const world = Fixtures.inRepository(on, Fixtures.TWO_FILES, {
16 hunksRefusal: () => refusal,
17 })
18
19 on('telemetry.mark', marked.hook)
20 on('tool.call', () => ({ result: 'ran' }))
21
22 await $.session.start(Fixtures.SESSION)
23 await $.command.run(Fixtures.DIFF)
24 await world.clock.advance(Fixtures.SETTLE_MS)
25
26 refusal = Fixtures.GIT_HUNG
27
28 await $.tool.call({ tool: 'Bash', command: 'make' })
29 await world.clock.advance(Fixtures.SETTLE_MS)
30
31 expect(
32 marked.kept.filter(mark => mark.feature === Record.FEATURES.read),
33 'one row a read: the counts came both times, the bodies once',
34 ).toEqual([
35 { feature: 'repl_diff_read', kind: 'ok' },
36 { feature: 'repl_diff_read', kind: 'sad', reason: 'git_hunks_failed' },
37 ])
38 })
39})