import { DataTable } from '@cucumber/cucumber'; import ContourDataTable from './ContourDataTable'; import scenarioContext from './scenarioContext'; export function generateOtherDocumentsJson(dataTable: DataTable, updateDocumentSource = false) { const returnJson = []; if (dataTable) { const colName = updateDocumentSource ? 'updatedValue' : 'value'; const table = new ContourDataTable(dataTable); const otherDocNames = table.getDataOnMatchedRow('field', 'Other Required Document Names', colName).split(','); const otherDocDescriptions = table .getDataOnMatchedRow('field', 'Other Required Document Descriptions', colName) .split(','); const otherDocCount = table.getDataOnMatchedRow('field', 'Other Required Document Count', colName); for (let i = 0; i < otherDocCount; i++) { returnJson.push({ documentType: otherDocNames[i], description: otherDocDescriptions[i], subtype: null }); } } scenarioContext().dc.otherDocumentsJson = returnJson; return returnJson; }