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 / views / layout / truncate-start.test.ts
30 lines · 875 BRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Views from '../../../hooks/views'
4import Fixtures from '../../fixtures'
5
6tier('builtin')
7
8describe('truncate-start', () => {
9 test('a path padded with combining marks is cut to the room', () => {
10 const cut = Views.truncateStart(
11 `src/${Fixtures.COMBINING_ACUTE.repeat(Fixtures.MARKS)}x.ts`,
12 Fixtures.ROOM,
13 )
14
15 expect([...cut].length).toBeLessThanOrEqual(Fixtures.ROOM)
16 expect(cut.startsWith('…')).toBe(true)
17 expect(cut.endsWith('x.ts')).toBe(true)
18 })
19
20 test('a path that fits is whole; one that does not keeps its tail', () => {
21 expect(Views.truncateStart('src/a.ts', Fixtures.ROOM)).toBe('src/a.ts')
22
23 expect(
24 Views.truncateStart(
25 'very/long/leading/dirs/file.ts',
26 Fixtures.NARROW_ROOM,
27 ),
28 ).toBe('…irs/file.ts')
29 })
30})