Skip to content

Commit

Permalink
Add type for return value
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-hoke committed Nov 10, 2023
1 parent 60414b6 commit 3812cb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/tdmlEditor/src/utilities/tdmlXmlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ type TDMLTestCaseDisplay = {
dfdlInfosets: string[]
}

type TDMLTestSuiteDisplay = {
suiteName: string
testCases: TDMLTestCaseDisplay[]
}

const testSuiteAttribute = 'suiteName'
const testCaseNameAttribute = 'name'
const testCaseDescriptionAttribute = 'description'
Expand Down Expand Up @@ -54,11 +59,14 @@ export async function readTDMLFileContents(tdmlFilePath: string) {

export async function getTestCaseDisplayData(
xmlBuffer: string
): Promise<[string, TDMLTestCaseDisplay[]]> {
): Promise<TDMLTestSuiteDisplay> {
const xmlDoc = parseXml(xmlBuffer)
const rootNode = xmlDoc.root
if (!rootNode) {
return ['', []]
return {
suiteName: '',
testCases: [],
}
}
const retVal: TDMLTestCaseDisplay[] = []

Expand Down Expand Up @@ -122,7 +130,10 @@ export async function getTestCaseDisplayData(
})
)

return [rootNode.attributes[testSuiteAttribute], retVal]
return {
suiteName: rootNode.attributes[testSuiteAttribute],
testCases: retVal,
}
}

export async function appendTestCase() {}
6 changes: 3 additions & 3 deletions src/tests/suite/tdmlXmlUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ suite('TDML Utils Test Suite', () => {
readTDMLFileContents('/home/mike/Git/daffodil-vscode/infoset.tdml').then(
(xmlBuffer) => {
console.log(xmlBuffer)
getTestCaseDisplayData(xmlBuffer).then((dataTuple) => {
console.log(dataTuple[0])
getTestCaseDisplayData(xmlBuffer).then((testSuiteData) => {
console.log(testSuiteData.suiteName)

dataTuple[1].forEach((testCaseDisplayData) => {
testSuiteData.testCases.forEach((testCaseDisplayData) => {
console.log(testCaseDisplayData.testCaseName)
console.log(testCaseDisplayData.testCaseDescription)
console.log(testCaseDisplayData.testCaseModel)
Expand Down

0 comments on commit 3812cb2

Please sign in to comment.