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 type Git from '../../hooks/git' |
| 4 | import PaneState from '../../hooks/pane-state' |
| 5 | import Fixtures from '../fixtures' |
| 6 | |
| 7 | tier('builtin') |
| 8 | |
| 9 | describe('has-session-files', () => { |
| 10 | const dataOf = ( |
| 11 | files: readonly Git.FileStat[], |
| 12 | overrides: Partial<Git.DiffData> = {}, |
| 13 | ): Git.FetchOutcome => ({ |
| 14 | kind: 'data', |
| 15 | data: { |
| 16 | repository: Fixtures.CHECKOUT, |
| 17 | mode: 'session', |
| 18 | stats: { ...Fixtures.NO_STATS, filesCount: files.length }, |
| 19 | files, |
| 20 | source: { kind: 'working-tree', base: 'HEAD' }, |
| 21 | isUnborn: false, |
| 22 | baseRef: 'HEAD', |
| 23 | stalePaths: [], |
| 24 | isUntrackedWithheld: false, |
| 25 | ...overrides, |
| 26 | }, |
| 27 | }) |
| 28 | |
| 29 | test("a file the header counts, a test among them: there's one", () => { |
| 30 | expect(PaneState.hasSessionFiles(dataOf([Fixtures.SESSION_ROW]))).toBe(true) |
| 31 | expect(PaneState.hasSessionFiles(dataOf([Fixtures.TEST_ROW]))).toBe(true) |
| 32 | |
| 33 | expect( |
| 34 | PaneState.hasSessionFiles( |
| 35 | dataOf([Fixtures.PRE_SESSION_ROW, Fixtures.SESSION_ROW]), |
| 36 | ), |
| 37 | ).toBe(true) |
| 38 | }) |
| 39 | |
| 40 | test('files counted past the row cap, none stored, still count', () => { |
| 41 | expect( |
| 42 | PaneState.hasSessionFiles( |
| 43 | dataOf([], { |
| 44 | stats: { ...Fixtures.NO_STATS, filesCount: Fixtures.PAST_CAP_COUNT }, |
| 45 | }), |
| 46 | ), |
| 47 | ).toBe(true) |
| 48 | }) |
| 49 | |
| 50 | test('wherever the pane would headline an empty state: none', () => { |
| 51 | const withheld = { isUntrackedWithheld: true } |
| 52 | |
| 53 | expect(PaneState.hasSessionFiles({ kind: 'no-repository' })).toBe(false) |
| 54 | expect(PaneState.hasSessionFiles({ kind: 'unavailable' })).toBe(false) |
| 55 | expect(PaneState.hasSessionFiles(dataOf([]))).toBe(false) |
| 56 | expect(PaneState.hasSessionFiles(dataOf([], withheld))).toBe(false) |
| 57 | expect(PaneState.hasSessionFiles(dataOf([], { isUnborn: true }))).toBe( |
| 58 | false, |
| 59 | ) |
| 60 | |
| 61 | expect(PaneState.hasSessionFiles(dataOf([Fixtures.PRE_SESSION_ROW]))).toBe( |
| 62 | false, |
| 63 | ) |
| 64 | }) |
| 65 | }) |