Files
adnify/tests/unit/shared/utils/gitNameStatus.test.ts
kerwin2046 db7e09c670 feat: enhance Git diff and file change handling
- Updated the Editor and EditorTabs components to improve file path handling for diffs, including support for commit and stash references.
- Added new translations for Git-related messages in English and Chinese.
- Introduced methods in GitService to retrieve changed files for commits and stashes, enhancing the ability to display file changes.
- Implemented a utility to parse `git --name-status` output for structured file change representation.
- Added unit tests for the new parsing utility to ensure accuracy and reliability and fix #159.
2026-08-21 16:19:59 +08:00

26 lines
756 B
TypeScript

import { describe, expect, it } from 'vitest'
import { parseGitNameStatus } from '@/shared/utils/gitNameStatus'
describe('parseGitNameStatus', () => {
it('parses added/modified/deleted entries', () => {
const result = parseGitNameStatus([
'M\tsrc/a.ts',
'A\tsrc/b.ts',
'D\tsrc/c.ts',
].join('\n'))
expect(result).toEqual([
{ status: 'modified', path: 'src/a.ts' },
{ status: 'added', path: 'src/b.ts' },
{ status: 'deleted', path: 'src/c.ts' },
])
})
it('parses renames with old and new paths', () => {
const result = parseGitNameStatus('R100\told/name.ts\tnew/name.ts\n')
expect(result).toEqual([
{ status: 'renamed', oldPath: 'old/name.ts', path: 'new/name.ts' },
])
})
})