spacehub

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

claude-code / mods / diff / tests / git / parse / parse-shortstat.test.ts
31 lines · 852 BRaw
1import { describe, expect, test, tier } from 'claude-code/testing'
2
3import Parse from '../../../hooks/git/parse'
4
5tier('builtin')
6
7describe('parse-shortstat', () => {
8 test('files, insertions and deletions; either tail optional', () => {
9 expect(
10 Parse.parseShortstat(
11 ' 3 files changed, 10 insertions(+), 2 deletions(-)\n',
12 ),
13 ).toEqual({ filesCount: 3, linesAdded: 10, linesRemoved: 2 })
14
15 expect(Parse.parseShortstat(' 1 file changed, 1 insertion(+)\n')).toEqual({
16 filesCount: 1,
17 linesAdded: 1,
18 linesRemoved: 0,
19 })
20
21 expect(Parse.parseShortstat(' 1 file changed, 4 deletions(-)\n')).toEqual({
22 filesCount: 1,
23 linesAdded: 0,
24 linesRemoved: 4,
25 })
26 })
27
28 test('an empty diff prints nothing and parses to null', () => {
29 expect(Parse.parseShortstat('')).toBeNull()
30 })
31})