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 / ask / fitted-ask-text-of.test.ts
33 lines · 927 BRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Ask from '../../hooks/ask'
4import Fixtures from '../fixtures'
5
6tier('builtin')
7
8describe('fitted-ask-text-of', () => {
9 test('an ask that fits rides whole', () => {
10 expect(
11 Ask.fittedAskTextOf(Fixtures.ASK_TEXT, Fixtures.ASK_TEXT.length),
12 ).toBe(Fixtures.ASK_TEXT)
13 })
14
15 test('an ask past the room keeps its first lines and the cut note', () => {
16 const fitted = Ask.fittedAskTextOf(
17 Fixtures.ASK_TEXT,
18 Fixtures.ROOM_FOR_TWO_LINES,
19 )
20
21 expect(fitted).toBe(
22 `${Fixtures.ASK_LINES.slice(0, 2).join('\n')}\n${Ask.ASK_CUT_NOTE}`,
23 )
24
25 expect(fitted?.length).toBeLessThanOrEqual(Fixtures.ROOM_FOR_TWO_LINES)
26 })
27
28 test('an ask whose first hunk line does not fit is not attached', () => {
29 expect(
30 Ask.fittedAskTextOf(Fixtures.ASK_TEXT, Fixtures.ROOM_FOR_ONE_LINE),
31 ).toBeUndefined()
32 })
33})