* Checks for deep inclusion of a provided json in a response data. * * ```js * // response.data == { user: { name: 'jon', email: 'jon@doe.com' } } * * I.seeResponseContainsKeys(['user']); * ``` * * If an array is received, check is performed for each element of array: *
(keys = [])
| 243 | * @param {array} keys |
| 244 | */ |
| 245 | seeResponseContainsKeys(keys = []) { |
| 246 | this._checkResponseReady() |
| 247 | if (Array.isArray(this.response.data)) { |
| 248 | for (const data of this.response.data) { |
| 249 | for (const key of keys) { |
| 250 | assert(key in data, `Key "${key}" is not found in ${JSON.stringify(data)}`) |
| 251 | } |
| 252 | } |
| 253 | } else { |
| 254 | for (const key of keys) { |
| 255 | assert(key in this.response.data, `Key "${key}" is not found in ${JSON.stringify(this.response.data)}`) |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Executes a callback function passing in `response` object and assert |
no test coverage detected