michael-hoke commented on code in PR #1336:
URL: https://github.com/apache/daffodil-vscode/pull/1336#discussion_r2254950213


##########
src/utils.ts:
##########
@@ -441,11 +441,26 @@ export function getTDMLTestCaseItems(
   const xml_obj = parser.parse(fileData)
 
   // Read through TDML test cases and populate each TDML test case item if XML 
file is valid enough
-  if (Array.isArray(xml_obj['testSuite']?.['parserTestCase'])) {
+  if (
+    // Otherwise, it's an array
+    Array.isArray(xml_obj['testSuite']?.['parserTestCase'])
+  ) {
     return xml_obj['testSuite']['parserTestCase'].map((obj) => ({
       name: obj['@_name'],
       description: obj['@_description'],
     }))
+  } else if (
+    // One item results in an object type
+    xml_obj['testSuite']?.['parserTestCase'] &&
+    typeof xml_obj['testSuite']?.['parserTestCase'] == 'object'
+  ) {
+    const obj = xml_obj['testSuite']?.['parserTestCase']
+    return [
+      {
+        name: obj['@_name'],
+        description: obj['@_description'],
+      },
+    ]
   } else {

Review Comment:
   I have changes incoming here due to the removal of the description. I just 
want to note the code I'm going to be putting in as it's very different than 
this - I don't think it makes sense to make any changes because of this (not 
even 100% sure that it would work with the description added back in, but it 
seems like it would). If I didn't have these description changes incoming, I'd 
probably want to push for something more concise.
   
   ```
   const raw_items = xml_obj['testSuite']?.['parserTestCase']
     const items = Array.isArray(raw_items)
       ? raw_items // Set items equal to the array of parserTestCase objects
       : raw_items
         ? [raw_items] // Set items equal to an array of the single object found
         : [] // Set items equal to an empty array
     return items.map((item) => { name: item['@_name'], description: 
item['@_description'] }) // Map the parserTestCase objects to the expected 
return format
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to