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('empty-state-of', () => { |
| 10 | const dataIn = ( |
| 11 | mode: Git.BaseMode, |
| 12 | overrides: Partial<Git.DiffData> = {}, |
| 13 | ): Git.DiffData => ({ |
| 14 | repository: Fixtures.CHECKOUT, |
| 15 | mode, |
| 16 | stats: Fixtures.NO_STATS, |
| 17 | files: [], |
| 18 | source: { kind: 'working-tree', base: 'HEAD' }, |
| 19 | isUnborn: false, |
| 20 | baseRef: 'HEAD', |
| 21 | stalePaths: [], |
| 22 | isUntrackedWithheld: false, |
| 23 | ...overrides, |
| 24 | }) |
| 25 | |
| 26 | const emptyOf = (data: Git.DiffData | null, filesCount: number) => |
| 27 | PaneState.emptyStateOf({ data, words: Git.GIT_WORDS }, filesCount) |
| 28 | |
| 29 | test("the built-in's headlines, keyed on the fetched mode", () => { |
| 30 | expect(emptyOf(null, 0)?.headline).toBe('Diff unavailable') |
| 31 | |
| 32 | expect(emptyOf(dataIn('session'), 0)).toEqual({ |
| 33 | headline: 'No changes this session', |
| 34 | hint: null, |
| 35 | }) |
| 36 | |
| 37 | expect(emptyOf(dataIn('uncommitted'), 0)?.headline).toBe( |
| 38 | 'No uncommitted changes', |
| 39 | ) |
| 40 | |
| 41 | expect( |
| 42 | emptyOf(dataIn('branch', { source: Fixtures.VS_MAIN }), 0)?.headline, |
| 43 | ).toBe('No changes vs main') |
| 44 | |
| 45 | expect(emptyOf(dataIn('branch'), 0)).toEqual({ |
| 46 | headline: 'No changes vs HEAD', |
| 47 | hint: 'No base branch to compare against — showing changes vs HEAD', |
| 48 | }) |
| 49 | |
| 50 | expect(emptyOf(dataIn('session', { isUnborn: true }), 0)).toEqual({ |
| 51 | headline: 'No commits yet', |
| 52 | hint: "Nothing to diff against until the repo's first commit", |
| 53 | }) |
| 54 | }) |
| 55 | |
| 56 | test('with files to count there is no empty state', () => { |
| 57 | expect(emptyOf(dataIn('session'), 2)).toBeNull() |
| 58 | }) |
| 59 | |
| 60 | test('no tracked rows, untracked withheld: claims no more', () => { |
| 61 | const withheld = { isUntrackedWithheld: true } |
| 62 | |
| 63 | expect(emptyOf(dataIn('session', withheld), 0)?.headline).toBe( |
| 64 | 'No tracked changes', |
| 65 | ) |
| 66 | |
| 67 | expect( |
| 68 | emptyOf(dataIn('session', { ...withheld, isUnborn: true }), 0)?.headline, |
| 69 | ).toBe('No tracked changes') |
| 70 | |
| 71 | expect(emptyOf(dataIn('uncommitted', withheld), 1)).toBeNull() |
| 72 | }) |
| 73 | }) |