Skip to content

Commit 0867de6

Browse files
committed
test(gemini-format): snapshot input in closeDanglingFunctionCalls no-op tests
What: In the two 'unchanged' tests, structuredClone the input contents before calling closeDanglingFunctionCalls and assert both the returned value and the input against that pre-call snapshot. Why: The helper mutates its input array in place and returns the same reference, so comparing the result to the (already mutated) input array was a self-comparison that could never fail, even if the helper appended an unwanted turn (CodeRabbit review on PR #1753). Impact: The no-op tests now genuinely pin 'no turn appended, input unmodified'; all synthesis assertions kept unchanged.
1 parent 9718cb8 commit 0867de6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎src/api/transform/__tests__/gemini-format.spec.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,15 @@ describe("closeDanglingFunctionCalls", () => {
729729
{ role: "user", parts: [{ text: "Hello" }] },
730730
{ role: "model", parts: [{ text: "Hi there!" }] },
731731
]
732+
// The helper mutates in place and returns the same array, so a
733+
// self-comparison against `contents` would be tautological. Snapshot
734+
// first, then pin both the returned parts and the untouched input.
735+
const snapshot = structuredClone(contents)
732736

733-
expect(closeDanglingFunctionCalls(contents)).toEqual(contents)
737+
const result = closeDanglingFunctionCalls(contents)
738+
739+
expect(result).toEqual(snapshot)
740+
expect(contents).toEqual(snapshot)
734741
})
735742

736743
it("leaves a completed tool turn unchanged", () => {
@@ -749,7 +756,11 @@ describe("closeDanglingFunctionCalls", () => {
749756
],
750757
},
751758
]
759+
const snapshot = structuredClone(contents)
760+
761+
const result = closeDanglingFunctionCalls(contents)
752762

753-
expect(closeDanglingFunctionCalls(contents)).toEqual(contents)
763+
expect(result).toEqual(snapshot)
764+
expect(contents).toEqual(snapshot)
754765
})
755766
})

0 commit comments

Comments
 (0)