Skip to content

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.

TypeScript
680 B
Raw Blame
import type { On } from 'claude-code'
import { mock } from 'claude-code/testing'
import type { MockClock } from 'claude-code/testing'

/**
 * Answers what every /diff session asks first: its start, with its own
 * directory, the time, and each command it registers, under its name.
 *
 * @param on the test's `on`
 * @param now where the clock starts, in milliseconds (0 when not given)
 * @returns the clock the session reads, at `now` until the test moves it
 */
export function startsSession(on: On, now = 0): MockClock {
  on('session.start', ($, e) => ({ cwd: e.cwd }))
  on('command.register', ($, e) => ({ value: { command: e.name } }))

  return mock.clock(on, { now })
}