michael-hoke commented on code in PR #1336:
URL: https://github.com/apache/daffodil-vscode/pull/1336#discussion_r2254963137
##########
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:
For me, this is a case where using a ternary operator makes sense. It's
relatively simple logic and we save a lot of repeated code. There are
definitely times where ternaries make code harder to read, I just don't think
this is one of them.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]