From 9231f09176a62e50e8e8028b5caed14e6d163689 Mon Sep 17 00:00:00 2001 From: yincg Date: Fri, 19 Dec 2025 16:45:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=89=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=9C=AA=E5=A4=84=E7=90=86=E7=9A=84merger=20=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/tests/editors/editors.test.ts | 68 ++++++++++----------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/packages/core/tests/editors/editors.test.ts b/packages/core/tests/editors/editors.test.ts index 1b4071a..c42f817 100644 --- a/packages/core/tests/editors/editors.test.ts +++ b/packages/core/tests/editors/editors.test.ts @@ -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({ - edits: [ - createWholeFileEdit(file1, 'new content 1'), - createWholeFileEdit(file2, 'new content 2'), - ], - }, { runDiagnostics: false }); + const result = await applyBatchEdits( + { + edits: [ + createWholeFileEdit(file1, 'new content 1'), + createWholeFileEdit(file2, 'new content 2'), + ], + }, + { 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({ - edits: [ - createWholeFileEdit(file1, 'new content 1'), - createSingleSearchReplaceEdit(file2, 'not found', 'replacement'), - ], - atomic: true, - }, { runDiagnostics: false }); + const result = await applyBatchEdits( + { + edits: [ + createWholeFileEdit(file1, 'new content 1'), + createSingleSearchReplaceEdit(file2, 'not found', 'replacement'), + ], + atomic: true, + }, + { 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({ - edits: [ - createWholeFileEdit(file1, 'line1\nline2\nline3'), - createWholeFileEdit(file2, 'x\ny'), - ], - }, { runDiagnostics: false }); + const result = await applyBatchEdits( + { + edits: [ + createWholeFileEdit(file1, 'line1\nline2\nline3'), + createWholeFileEdit(file2, 'x\ny'), + ], + }, + { runDiagnostics: false }, + ); expect(result.success).toBe(true); expect(result.totalStats.blocksApplied).toBe(2);