Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 26, 2021 14:20
Show Gist options
  • Save sergueyarellano/c174d8e798dc3ffe1376fd7647e6e912 to your computer and use it in GitHub Desktop.
Save sergueyarellano/c174d8e798dc3ffe1376fd7647e6e912 to your computer and use it in GitHub Desktop.
defineStep('every element on {string} property has {string}', async function (property, option, table) {
const propFromResponse = get(this.response, property, {})
if (option === 'interface') {
const model = table.rowsHash() // to format a table of 2 columns
const actual = isValidInterface(propFromResponse, model)
const expected = true
deepStrictEqual(actual, expected)
} else if (option === 'restrictions') {
// table hashes: [ { property: 'distance', operator: 'less than', value: '200' } ]
// table rows: [ [ 'distance', 'less than', '200' ] ]
const restrictions = table.hashes()
const actual = complyWith(propFromResponse, restrictions)
const expected = true
deepStrictEqual(actual, expected)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment