containsKey method

void containsKey(
  1. K key
)

Expects that the map contains key according to Map.containsKey.

Implementation

void containsKey(K key) {
  context.expect(
    () => prefixFirst('contains key ', literal(key)),
    predicateNoun: () {
      final l = literal(key).singleOrNull;
      return l != null ? 'a map with key $l' : null;
    },
    (actual) {
      if (actual.containsKey(key)) return null;
      return Rejection(
        which: prefixFirst('does not contain key ', literal(key)),
      );
    },
  );
}