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('base-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 | data: Git.DiffData | null, |
| 28 | filesCount: number, |
| 29 | ) => |
| 30 | PaneState.baseLabelOf( |
| 31 | { requestedMode: mode, data, words: Git.GIT_WORDS }, |
| 32 | filesCount, |
| 33 | ) |
| 34 | |
| 35 | test('settled session mode and no data show no line', () => { |
| 36 | expect( |
| 37 | labelOf('session', dataIn('session', Fixtures.WORKING_TREE), 1), |
| 38 | ).toBeNull() |
| 39 | |
| 40 | expect(labelOf('branch', null, 0)).toBeNull() |
| 41 | }) |
| 42 | |
| 43 | test('settled pinned modes name their base', () => { |
| 44 | expect( |
| 45 | labelOf('uncommitted', dataIn('uncommitted', Fixtures.WORKING_TREE), 1), |
| 46 | ).toBe('uncommitted (vs HEAD)') |
| 47 | |
| 48 | expect(labelOf('branch', dataIn('branch', Fixtures.VS_MAIN), 1)).toBe( |
| 49 | 'branch vs main', |
| 50 | ) |
| 51 | |
| 52 | expect(labelOf('branch', dataIn('branch', Fixtures.WORKING_TREE), 1)).toBe( |
| 53 | 'vs HEAD (no base branch)', |
| 54 | ) |
| 55 | }) |
| 56 | |
| 57 | test('a working tree that names its own base shows that name', () => { |
| 58 | expect( |
| 59 | labelOf('uncommitted', dataIn('uncommitted', Fixtures.AT_SHA), 1), |
| 60 | ).toBe('uncommitted (vs 8634408015c1)') |
| 61 | }) |
| 62 | |
| 63 | test('a pending mode shows with an ellipsis, session too', () => { |
| 64 | expect(labelOf('branch', dataIn('session', Fixtures.WORKING_TREE), 1)).toBe( |
| 65 | 'branch diff…', |
| 66 | ) |
| 67 | |
| 68 | expect(labelOf('session', dataIn('branch', Fixtures.VS_MAIN), 1)).toBe( |
| 69 | 'this session…', |
| 70 | ) |
| 71 | }) |
| 72 | }) |