wasCalled static method

bool wasCalled(
  1. String endpoint, {
  2. String? method,
  3. int? times,
})

Check if an endpoint was called.

Implementation

static bool wasCalled(String endpoint, {String? method, int? times}) {
  final calls = getCallsFor(endpoint).where((c) {
    if (method != null && c.method != method.toUpperCase()) return false;
    return true;
  }).toList();

  if (times != null) {
    return calls.length == times;
  }
  return calls.isNotEmpty;
}