mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
- Added unit tests to verify correct handling of patterns like data?.[0]?.value - Tests confirm the escapeRegExp function works correctly with these patterns - Issue appears to be Gemini-specific parameter handling, not core functionality
30 lines
681 B
JavaScript
30 lines
681 B
JavaScript
// Test file for array accessor and optional chaining issue
|
|
const data = {
|
|
items: [
|
|
{ name: "first", values: [1, 2, 3] },
|
|
{ name: "second", values: [4, 5, 6] },
|
|
],
|
|
}
|
|
|
|
// Original code with array accessors and optional chaining
|
|
const result1 = data?.items?.[0]?.values?.[1]
|
|
const result2 = data?.items?.[1]?.values?.[2]
|
|
|
|
// More complex example
|
|
const complexData = {
|
|
nested: {
|
|
arrays: [
|
|
[{ id: 1 }, { id: 2 }],
|
|
[{ id: 3 }, { id: 4 }],
|
|
],
|
|
},
|
|
}
|
|
|
|
const complexResult = complexData?.nested?.arrays?.[0]?.[1]?.id
|
|
|
|
// Function with optional chaining
|
|
function getValue(obj) {
|
|
return obj?.data?.[0]?.value?.[1]
|
|
}
|
|
|
|
console.log("Results:", result1, result2, complexResult)
|