expectApiCalled function

void expectApiCalled(
  1. String endpoint, {
  2. String? method,
  3. int? times,
})

Assert that an API endpoint was called.

Implementation

void expectApiCalled(String endpoint, {String? method, int? times}) {
  final wasCalled = NyMockApi.wasCalled(endpoint, method: method, times: times);
  if (times != null) {
    expect(
      wasCalled,
      isTrue,
      reason: 'Expected "$endpoint" to be called $times time(s)',
    );
  } else {
    expect(
      wasCalled,
      isTrue,
      reason: 'Expected "$endpoint" to have been called',
    );
  }
}