Compare commits

..

1 Commits

Author SHA1 Message Date
yincg 9231f09176 fix: 修复掉一些未处理的merger 冲突 2025-12-19 16:45:15 +08:00
+19 -23
View File
@@ -26,11 +26,7 @@ describe('Edit Parsers', () => {
describe('parseSearchReplaceBlocks', () => {
it('should parse marker format blocks', () => {
const content = `
<<<<<<< SEARCH
old content
=======
new content
>>>>>>> REPLACE
`;
const blocks = parseSearchReplaceBlocks(content);
expect(blocks).toHaveLength(1);
@@ -40,17 +36,8 @@ new content
it('should parse multiple marker format blocks', () => {
const content = `
<<<<<<< SEARCH
first old
=======
first new
>>>>>>> REPLACE
<<<<<<< SEARCH
second old
=======
second new
>>>>>>> REPLACE
`;
const blocks = parseSearchReplaceBlocks(content);
expect(blocks).toHaveLength(2);
@@ -81,9 +68,7 @@ second new
describe('createSearchReplaceEdit', () => {
it('should create search-replace edit', () => {
const blocks: SearchReplaceBlock[] = [
{ search: 'old', replace: 'new' },
];
const blocks: SearchReplaceBlock[] = [{ search: 'old', replace: 'new' }];
const edit = createSearchReplaceEdit('/test/file.ts', blocks);
expect(edit.mode).toBe('search-replace');
expect(edit.blocks).toHaveLength(1);
@@ -124,7 +109,9 @@ new
it('should trim trailing whitespace', () => {
const input = 'line1 \nline2 ';
const result = normalizeSearchString(input, { trimTrailingWhitespace: true });
const result = normalizeSearchString(input, {
trimTrailingWhitespace: true,
});
expect(result).toBe('line1\nline2');
});
});
@@ -331,12 +318,15 @@ describe('Edit Applier', () => {
await fs.writeFile(file1, 'content 1');
await fs.writeFile(file2, 'content 2');
const result = await applyBatchEdits({
const result = await applyBatchEdits(
{
edits: [
createWholeFileEdit(file1, 'new content 1'),
createWholeFileEdit(file2, 'new content 2'),
],
}, { runDiagnostics: false });
},
{ runDiagnostics: false },
);
expect(result.success).toBe(true);
expect(result.results).toHaveLength(2);
@@ -353,13 +343,16 @@ describe('Edit Applier', () => {
await fs.writeFile(file1, 'original 1');
await fs.writeFile(file2, 'original 2');
const result = await applyBatchEdits({
const result = await applyBatchEdits(
{
edits: [
createWholeFileEdit(file1, 'new content 1'),
createSingleSearchReplaceEdit(file2, 'not found', 'replacement'),
],
atomic: true,
}, { runDiagnostics: false });
},
{ runDiagnostics: false },
);
expect(result.success).toBe(false);
@@ -374,12 +367,15 @@ describe('Edit Applier', () => {
await fs.writeFile(file1, 'line1\nline2');
await fs.writeFile(file2, 'a\nb\nc');
const result = await applyBatchEdits({
const result = await applyBatchEdits(
{
edits: [
createWholeFileEdit(file1, 'line1\nline2\nline3'),
createWholeFileEdit(file2, 'x\ny'),
],
}, { runDiagnostics: false });
},
{ runDiagnostics: false },
);
expect(result.success).toBe(true);
expect(result.totalStats.blocksApplied).toBe(2);