import { DataTable } from '@cucumber/cucumber'; /** * * * @export * @class ContourDataTable * @extends {DataTable} https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/data_table_interface.md */ export default class ContourDataTable extends DataTable { constructor(dataTable: DataTable) { super(dataTable.raw()); } /** *Return the 1st row that matched the finding condition, and undefined * otherwise. * * @param {string} findingColumn * @param {string} findingValue * @return {*} {*} * @memberof ContourDataTable */ findRow(findingColumn: string, findingValue: string): any { const data = this.hashes(); return data.find((item) => item[findingColumn] === findingValue); } /** *Find the 1st row that matched the finding condition then extract the value in dataColumn, * and undefined otherwise. * * @param {string} findingColumn * @param {string} findingValue * @param {string} dataColumn * @return {*} {*} * @memberof ContourDataTable */ getDataOnMatchedRow(findingColumn: string, findingValue: string, dataColumn: string): any { let result = undefined; const data = this.findRow(findingColumn, findingValue); data && (result = data[dataColumn]); return result; } }