headersHas function

Checker<Response> headersHas(
  1. String header, [
  2. String? value
])

Implementation

Checker<Response> headersHas(String header, [String? value]) =>
    (Response resp) {
      if (!resp.headers.containsKey(header))
        return <Mismatch>[
          new MapHasMismatch(header,
              customMessage: (m) => 'Expected header ${m.key} is not found!')
        ];
      if (value != null) {
        if (resp.headers[header] != value)
          return <Mismatch>[
            new EqualityMismatch(value, resp.headers[header],
                customMessage: (m) =>
                    'Header $header is expected to have value ${m.expected} but found ${m.actual}!')
          ];
      }
      return <Mismatch>[];
    };