Skip to content

Commit

Permalink
Testing git.diffSummary from empty tree to first commit
Browse files Browse the repository at this point in the history
Relates to #1035
  • Loading branch information
steveukx committed Dec 31, 2024
1 parent 95c556f commit 9d45685
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions simple-git/test/integration/diff-summary.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
})
);
});
});
});

0 comments on commit 9d45685

Please sign in to comment.