I am facing an issue with a data table that contains a list of states and messages which I need to validate in a particular scenario.
Given user inputs "<state>" and sees "<message>" message
| state | message |
| Deactivated | error |
| Taken | error |
| Unused | confirmation |
Despite my efforts, the script provided below only executes actions based on the 'state' values without considering the corresponding 'message' actions.
Given(‘user inputs {string} and sees {string} message’, (dataTable: DataTable) => {
dataTable.hashes().forEach(elem =>{
if(elem.state == 'Deactivated') {
<DeactivatedAction>
} else if(elem.state == 'Taken') {
<TakenAction>
} else if(elem.state == 'Unused') {
<UnusedAction>
} else {
throw new Error("No state defined")
}
})
dataTable.hashes().forEach(elem =>{
if(elem.message == 'error') {
<errorAction>
} else if(elem.message == 'confirmation') {
<confirmationAction>
} else {
throw new Error("No state defined")
}
})
}
Even when attempting to change from .forEach()
to .map()
, the issue persists. :/