Download mods/diff/tests/pane-state/empty-state-of.test.ts from SaylorTwift/claude-code: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/tests/pane-state/empty-state-of.test.ts
- Command line
-
hf download hf://SaylorTwift/claude-code/mods/diff/tests/pane-state/empty-state-of.test.ts
-
curl -L -o empty-state-of.test.ts https://huggingface.co/SaylorTwift/claude-code/resolve/main/mods/diff/tests/pane-state/empty-state-of.test.ts
2.14 kB
| import { describe, expect, test, tier } from 'claude-code/testing' | |
| import Git from '../../hooks/git' | |
| import PaneState from '../../hooks/pane-state' | |
| import Fixtures from '../fixtures' | |
| tier('builtin') | |
| describe('empty-state-of', () => { | |
| const dataIn = ( | |
| mode: Git.BaseMode, | |
| overrides: Partial<Git.DiffData> = {}, | |
| ): Git.DiffData => ({ | |
| repository: Fixtures.CHECKOUT, | |
| mode, | |
| stats: Fixtures.NO_STATS, | |
| files: [], | |
| source: { kind: 'working-tree', base: 'HEAD' }, | |
| isUnborn: false, | |
| baseRef: 'HEAD', | |
| stalePaths: [], | |
| isUntrackedWithheld: false, | |
| ...overrides, | |
| }) | |
| const emptyOf = (data: Git.DiffData | null, filesCount: number) => | |
| PaneState.emptyStateOf({ data, words: Git.GIT_WORDS }, filesCount) | |
| test("the built-in's headlines, keyed on the fetched mode", () => { | |
| expect(emptyOf(null, 0)?.headline).toBe('Diff unavailable') | |
| expect(emptyOf(dataIn('session'), 0)).toEqual({ | |
| headline: 'No changes this session', | |
| hint: null, | |
| }) | |
| expect(emptyOf(dataIn('uncommitted'), 0)?.headline).toBe( | |
| 'No uncommitted changes', | |
| ) | |
| expect( | |
| emptyOf(dataIn('branch', { source: Fixtures.VS_MAIN }), 0)?.headline, | |
| ).toBe('No changes vs main') | |
| expect(emptyOf(dataIn('branch'), 0)).toEqual({ | |
| headline: 'No changes vs HEAD', | |
| hint: 'No base branch to compare against — showing changes vs HEAD', | |
| }) | |
| expect(emptyOf(dataIn('session', { isUnborn: true }), 0)).toEqual({ | |
| headline: 'No commits yet', | |
| hint: "Nothing to diff against until the repo's first commit", | |
| }) | |
| }) | |
| test('with files to count there is no empty state', () => { | |
| expect(emptyOf(dataIn('session'), 2)).toBeNull() | |
| }) | |
| test('no tracked rows, untracked withheld: claims no more', () => { | |
| const withheld = { isUntrackedWithheld: true } | |
| expect(emptyOf(dataIn('session', withheld), 0)?.headline).toBe( | |
| 'No tracked changes', | |
| ) | |
| expect( | |
| emptyOf(dataIn('session', { ...withheld, isUnborn: true }), 0)?.headline, | |
| ).toBe('No tracked changes') | |
| expect(emptyOf(dataIn('uncommitted', withheld), 1)).toBeNull() | |
| }) | |
| }) | |