assertJsonContains method
Asserts decoded JSON contains expected as a subset.
For maps, every key in expected must be present with the same value.
Implementation
void assertJsonContains(Object? expected) {
final decoded = json;
if (expected is Map && decoded is Map) {
for (final entry in expected.entries) {
if (!decoded.containsKey(entry.key) ||
!_deepEquals(decoded[entry.key], entry.value)) {
throw TestAssertionError(
'expected JSON to contain {${entry.key}: ${entry.value}}, '
'got $decoded');
}
}
} else {
assertJson(expected);
}
}