feat(compare): implement Document Compare dialog with local-diff and git-HEAD-diff modes

Amit Haridas
This commit is contained in:
2026-08-23 19:31:33 +05:30
parent 1f5db511ba
commit 758dcb4166
10 changed files with 769 additions and 3 deletions
+18
View File
@@ -43,6 +43,24 @@ describe('GitOperations', () => {
expect(result).toHaveProperty('error');
fs.rmSync(nonGitDir, { recursive: true, force: true });
});
test('includes staged changes when againstHead is true', async () => {
fs.writeFileSync(filePath, 'line1\nline2\n');
await simpleGit(tmpDir).add('file.txt');
const unstaged = await GitOperations.diff(tmpDir, 'file.txt');
expect(unstaged).toBe('');
const againstHead = await GitOperations.diff(tmpDir, 'file.txt', true);
expect(againstHead).toContain('+line2');
});
test('returns error object for non-git directory when againstHead is true', async () => {
const nonGitDir = fs.mkdtempSync(path.join(os.tmpdir(), 'notgit_'));
const result = await GitOperations.diff(nonGitDir, null, true);
expect(result).toHaveProperty('error');
fs.rmSync(nonGitDir, { recursive: true, force: true });
});
});
describe('branches', () => {