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
| 1 | import { describe, expect, test, tier } from 'claude-code/testing' |
| 2 | |
| 3 | import Git from '../../hooks/git' |
| 4 | import PaneState from '../../hooks/pane-state' |
| 5 | import Fixtures from '../fixtures' |
| 6 | |
| 7 | tier('builtin') |
| 8 | |
| 9 | describe('mode-label-of', () => { |
| 10 | const dataIn = ( |
| 11 | mode: Git.BaseMode, |
| 12 | source: Git.DiffSource, |
| 13 | ): Git.DiffData => ({ |
| 14 | repository: Fixtures.CHECKOUT, |
| 15 | mode, |
| 16 | stats: Fixtures.ONE_FILE, |
| 17 | files: [], |
| 18 | source, |
| 19 | isUnborn: false, |
| 20 | baseRef: 'HEAD', |
| 21 | stalePaths: [], |
| 22 | isUntrackedWithheld: false, |
| 23 | }) |
| 24 | |
| 25 | const labelOf = ( |
| 26 | mode: Git.BaseMode, |
| 27 | requestedMode: Git.BaseMode, |
| 28 | data: Git.DiffData | null, |
| 29 | ) => |
| 30 | PaneState.modeLabelOf(mode, { requestedMode, data, words: Git.GIT_WORDS }) |
| 31 | |
| 32 | test('each settled mode is named as the built-in names it', () => { |
| 33 | const session = dataIn('session', Fixtures.WORKING_TREE) |
| 34 | |
| 35 | expect(labelOf('session', 'session', session)).toBe('this session') |
| 36 | |
| 37 | expect(labelOf('uncommitted', 'session', session)).toBe( |
| 38 | 'uncommitted (vs HEAD)', |
| 39 | ) |
| 40 | |
| 41 | expect(labelOf('branch', 'session', session)).toBe('branch diff') |
| 42 | }) |
| 43 | |
| 44 | test('settled branch mode names its base, or what stands in', () => { |
| 45 | expect( |
| 46 | labelOf('branch', 'branch', dataIn('branch', Fixtures.VS_MAIN)), |
| 47 | ).toBe('branch vs main') |
| 48 | |
| 49 | expect( |
| 50 | labelOf('branch', 'branch', dataIn('branch', Fixtures.WORKING_TREE)), |
| 51 | ).toBe('vs HEAD (no base branch)') |
| 52 | }) |
| 53 | |
| 54 | test('a working tree that names its own base shows that name', () => { |
| 55 | expect( |
| 56 | labelOf( |
| 57 | 'uncommitted', |
| 58 | 'uncommitted', |
| 59 | dataIn('uncommitted', Fixtures.AT_SHA), |
| 60 | ), |
| 61 | ).toBe('uncommitted (vs 8634408015c1)') |
| 62 | }) |
| 63 | |
| 64 | test('the requested mode pends with an ellipsis until its data lands', () => { |
| 65 | const session = dataIn('session', Fixtures.WORKING_TREE) |
| 66 | |
| 67 | expect(labelOf('branch', 'branch', session)).toBe('branch diff…') |
| 68 | expect(labelOf('session', 'branch', session)).toBe('this session') |
| 69 | |
| 70 | expect( |
| 71 | labelOf('session', 'session', dataIn('branch', Fixtures.VS_MAIN)), |
| 72 | ).toBe('this session…') |
| 73 | |
| 74 | expect(labelOf('branch', 'branch', null)).toBe('branch diff') |
| 75 | }) |
| 76 | |
| 77 | test('an unborn HEAD with rows says what the rows are', () => { |
| 78 | const unborn = { |
| 79 | ...dataIn('session', Fixtures.WORKING_TREE), |
| 80 | isUnborn: true, |
| 81 | } |
| 82 | |
| 83 | expect(PaneState.unbornNoteOf({ data: unborn }, 2)).toBe( |
| 84 | 'no commits yet — showing staged and new files', |
| 85 | ) |
| 86 | |
| 87 | expect(PaneState.unbornNoteOf({ data: unborn }, 0)).toBeNull() |
| 88 | |
| 89 | expect( |
| 90 | PaneState.unbornNoteOf({ data: dataIn('session', Fixtures.VS_MAIN) }, 2), |
| 91 | ).toBeNull() |
| 92 | }) |
| 93 | }) |