Skip to content

Commit

Permalink
Use _.compact/map.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jun 19, 2024
1 parent 92d151e commit 04ff544
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tools/src/tester/ChapterEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@ export default class ChapterEvaluator {
#evaluate_payload_body(response: ActualResponse, expected_payload?: Payload): Evaluation {
if (expected_payload == null) return { result: Result.PASSED }
const delta = atomizeChangeset(diff(expected_payload, response.payload))
var messages: string[] = []
delta.forEach((value, _index, _array) => {
var messages: string[] = _.compact(delta.map((value, _index, _array) => {
switch(value.type) {
case Operation.UPDATE:
return messages.push(`expected ${value.path.replace('$.', '')}='${value.oldValue}', got '${value.value}'`)
return `expected ${value.path.replace('$.', '')}='${value.oldValue}', got '${value.value}'`
case Operation.REMOVE:
return messages.push(`missing ${value.path.replace('$.', '')}='${value.value}'`)
return `missing ${value.path.replace('$.', '')}='${value.value}'`
}
})
}))
return messages.length > 0 ? { result: Result.FAILED, message: _.join(messages, ', ')} : { result: Result.PASSED }
}

Expand Down

0 comments on commit 04ff544

Please sign in to comment.