mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
chore: Add more multi-block tests for apply_diff tool (#2261)
This commit is contained in:
parent
a3e6c912b0
commit
552ed0e986
1 changed files with 48 additions and 0 deletions
|
|
@ -76,6 +76,54 @@ function hello() {
|
|||
}
|
||||
})
|
||||
|
||||
it("should replace matching content in multiple blocks", async () => {
|
||||
const originalContent = 'function hello() {\n console.log("hello")\n}\n'
|
||||
const diffContent = `test.ts
|
||||
<<<<<<< SEARCH
|
||||
function hello() {
|
||||
=======
|
||||
function helloWorld() {
|
||||
>>>>>>> REPLACE
|
||||
<<<<<<< SEARCH
|
||||
console.log("hello")
|
||||
=======
|
||||
console.log("hello world")
|
||||
>>>>>>> REPLACE`
|
||||
|
||||
const result = await strategy.applyDiff(originalContent, diffContent)
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.content).toBe('function helloWorld() {\n console.log("hello world")\n}\n')
|
||||
}
|
||||
})
|
||||
|
||||
it("should replace matching content in multiple blocks with line numbers", async () => {
|
||||
const originalContent = 'function hello() {\n console.log("hello")\n}\n'
|
||||
const diffContent = `test.ts
|
||||
<<<<<<< SEARCH
|
||||
:start_line:1
|
||||
:end_line:1
|
||||
-------
|
||||
function hello() {
|
||||
=======
|
||||
function helloWorld() {
|
||||
>>>>>>> REPLACE
|
||||
<<<<<<< SEARCH
|
||||
:start_line:2
|
||||
:end_line:2
|
||||
-------
|
||||
console.log("hello")
|
||||
=======
|
||||
console.log("hello world")
|
||||
>>>>>>> REPLACE`
|
||||
|
||||
const result = await strategy.applyDiff(originalContent, diffContent)
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.content).toBe('function helloWorld() {\n console.log("hello world")\n}\n')
|
||||
}
|
||||
})
|
||||
|
||||
it("should match content with different surrounding whitespace", async () => {
|
||||
const originalContent = "\nfunction example() {\n return 42;\n}\n\n"
|
||||
const diffContent = `test.ts
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue