jsonEquals method
Asserts the JSON body matches the expected map.
This method is async.
Implementation
Future<ResponseExpect> jsonEquals(Map<String, dynamic> expected) async {
final json = await _response.json;
if (json is! Map) {
throw ChaseTestFailure(
'Expected JSON object but got ${json.runtimeType}',
);
}
for (final entry in expected.entries) {
if (json[entry.key] != entry.value) {
throw ChaseTestFailure(
'JSON key "${entry.key}": expected "${entry.value}" but got "${json[entry.key]}"',
);
}
}
return this;
}