From 9d45685a5a73dc93ad995292cfbdca9a3b3e1a9a Mon Sep 17 00:00:00 2001 From: Steve King Date: Tue, 31 Dec 2024 16:33:41 +0200 Subject: [PATCH] Testing `git.diffSummary` from empty tree to first commit Relates to #1035 --- .../test/integration/diff-summary.spec.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 simple-git/test/integration/diff-summary.spec.ts diff --git a/simple-git/test/integration/diff-summary.spec.ts b/simple-git/test/integration/diff-summary.spec.ts new file mode 100644 index 00000000..bdfff8e4 --- /dev/null +++ b/simple-git/test/integration/diff-summary.spec.ts @@ -0,0 +1,30 @@ +import { like, newSimpleGit } from '@simple-git/test-utils'; + +describe('diffSummary', () => { + it('empty tree to first commit', async () => { + const git = newSimpleGit(); + const emptyCommit = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; + const firstCommit = await git.firstCommit(); + + const task = git.diffSummary([emptyCommit, firstCommit]); + const result = await task; + + expect(result.changed).toBeGreaterThan(0); + expect(result.changed).toBe(result.files.length); + expect(result.insertions).toBeGreaterThan(0); + expect(result.deletions).toBe(0); + result.files.forEach((file) => { + if (file.binary) { + throw new Error(`Test assumes no binary files in first commit`); + } + + expect(file.insertions).toBe(file.changes); + expect(file).toEqual( + like({ + changes: file.insertions, + deletions: 0, + }) + ); + }); + }); +});