containsKeyThat method

void containsKeyThat(
  1. Condition<K> keyCondition
)

Expects that the map contains some key such that keyCondition is satisfied.

Implementation

void containsKeyThat(Condition<K> keyCondition) {
  context.expect(() {
    final conditionDescription = describe(keyCondition);
    assert(conditionDescription.isNotEmpty);
    return [
      'contains a key that:',
      ...conditionDescription,
    ];
  }, (actual) {
    if (actual.isEmpty) return Rejection(actual: ['an empty map']);
    for (var k in actual.keys) {
      if (softCheck(k, keyCondition) == null) return null;
    }
    return Rejection(which: ['Contains no matching key']);
  });
}