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 / fixtures / starts-session.ts
18 lines · 680 BRaw
1import type { On } from 'claude-code'
2import { mock } from 'claude-code/testing'
3import type { MockClock } from 'claude-code/testing'
4
5/**
6 * Answers what every /diff session asks first: its start, with its own
7 * directory, the time, and each command it registers, under its name.
8 *
9 * @param on the test's `on`
10 * @param now where the clock starts, in milliseconds (0 when not given)
11 * @returns the clock the session reads, at `now` until the test moves it
12 */
13export function startsSession(on: On, now = 0): MockClock {
14 on('session.start', ($, e) => ({ cwd: e.cwd }))
15 on('command.register', ($, e) => ({ value: { command: e.name } }))
16
17 return mock.clock(on, { now })
18}