Created
July 2, 2022 18:34
-
-
Save danahartweg/c0aaa956b73f4f3052b21aa0fac4ea09 to your computer and use it in GitHub Desktop.
Query test harness - Unit testing Flutter GraphQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MockQueryResult<T> generateMockQuery<T>(MockGraphQLClient graphQLClient) { | |
registerFallbackValue(_FakeQueryOptions<T>()); | |
final result = MockQueryResult<T>(); | |
when(() => graphQLClient.query<T>(any())).thenAnswer((_) async => result); | |
final queryManager = graphQLClient.queryManager; | |
when(() => queryManager.query<T>(any())).thenAnswer((_) async => result); | |
return result; | |
} | |
class MockQueryResult<T> extends Mock implements QueryResult<T> {} | |
class _FakeQueryOptions<T> extends Fake implements QueryOptions<T> {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment