stubDownload method

void stubDownload(
  1. String endpoint, {
  2. int statusCode = 200,
})

Stubs a download call, which is recorded under HttpMethod.get.

The savePath is captured as the recorded call's data, so a test can assert where the file would have been written:

api.stubDownload('/files/report.pdf');
await repository.fetchReport();
expect(api.recordedCalls.single.data, endsWith('report.pdf'));

Implementation

void stubDownload(String endpoint, {int statusCode = 200}) {
  stubJson(HttpMethod.get, endpoint, null, statusCode: statusCode);
}