stubJson method

void stubJson(
  1. HttpMethod method,
  2. String endpoint,
  3. Object? body, {
  4. int statusCode = 200,
  5. Map<String, List<String>>? headers,
})

Stubs a successful JSON response — the common case.

Implementation

void stubJson(
  HttpMethod method,
  String endpoint,
  Object? body, {
  int statusCode = 200,
  Map<String, List<String>>? headers,
}) {
  stub(
    method,
    endpoint,
    right(Response(
      requestOptions: RequestOptions(path: endpoint),
      statusCode: statusCode,
      data: body,
      headers: headers == null ? null : Headers.fromMap(headers),
    )),
  );
}