Skip to content

Testing #12

Closed Answered by lishaduck
lishaduck asked this question in Q&A
Discussion options

You must be logged in to vote

This worked: ResponseBody(Stream.value(TileProvider.transparentImage), 200).

(Fuller code)

class MockDioAdapter extends Mock implements HttpClientAdapter {}

HttpClientAdapter _getMockAdapter() {
  final mockDioAdapter = MockDioAdapter();
  // ignore: discarded_futures - Must not be async for Mocktail to work.
  when(() => mockDioAdapter.fetch(any(), any(), any())).thenAnswer(
    (_) => Future.value(
      ResponseBody(Stream.value(TileProvider.transparentImage), 200),
    ),
  );

  return mockDioAdapter;
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lishaduck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant