mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-23 23:10:17 +05:30
feat(compare): implement Document Compare dialog with local-diff and git-HEAD-diff modes
Amit Haridas
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user