fixes and build 0.1.0
Some checks failed
CI / check (push) Has been cancelled

This commit is contained in:
2026-09-04 09:43:04 +02:00
parent e5f739ec24
commit bccc97c11c
14 changed files with 233 additions and 60 deletions

35
test/group-by-dir.test.ts Normal file
View File

@@ -0,0 +1,35 @@
import { describe, expect, it } from 'vitest'
import { groupByDir } from '../src/renderer/src/components'
import type { Change } from '../src/renderer/src/types'
function change(path: string): Change {
return { path, status: 'M', add: 1, del: 0, deleted: false, staged: false, id: path }
}
describe('groupByDir', () => {
it('gives one group per folder when git returns the folder in separated runs', () => {
const groups = groupByDir([
change('tests/Feature/AlphaTest.php'),
change('app/Models/User.php'),
change('tests/Feature/BetaTest.php'),
])
expect(groups.map((g) => g.dir)).toEqual(['tests/Feature', 'app/Models'])
expect(groups[0].rows.map((r) => r.path)).toEqual([
'tests/Feature/AlphaTest.php',
'tests/Feature/BetaTest.php',
])
})
it('keeps every row, so the keyboard cursor walks the full list', () => {
const list = ['a/one.ts', 'b/two.ts', 'a/three.ts', 'four.ts'].map(change)
const flat = groupByDir(list).flatMap((g) => g.rows)
expect(flat).toHaveLength(list.length)
expect(new Set(flat.map((r) => r.id)).size).toBe(list.length)
})
it('puts a project-root file in the empty-string group', () => {
expect(groupByDir([change('README.md')])).toEqual([
{ dir: '', rows: [change('README.md')] },
])
})
})