From 86c8386488cec117f15d5ef671dd812a0d049777 Mon Sep 17 00:00:00 2001 From: Ayush Raghuwanshi <62144720+AyushRaghuvanshi@users.noreply.github.com> Date: Wed, 3 Jan 2024 10:19:40 +0530 Subject: [PATCH] Add: GraphQl Test (#2298) --- test/service_tests/graphql_config_test.dart | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/service_tests/graphql_config_test.dart diff --git a/test/service_tests/graphql_config_test.dart b/test/service_tests/graphql_config_test.dart new file mode 100644 index 0000000000..201b1aafcc --- /dev/null +++ b/test/service_tests/graphql_config_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:graphql_flutter/graphql_flutter.dart'; +import 'package:talawa/services/graphql_config.dart'; +import '../helpers/test_helpers.dart'; +import '../helpers/test_locator.dart'; + +void main() { + testSetupLocator(); + + setUp(() { + registerServices(); + }); + group('Testing Graphql Config', () { + test('test httpLink with MockHttpClient', () async { + final graphqlConfig = GraphqlConfig(); + final mockHttpClient = MockHttpClient(); + final mockUri = Uri.parse('https://example.com/graphql'); + + graphqlConfig.httpLink = HttpLink( + mockUri.toString(), + httpClient: mockHttpClient, + ); + + final response = await graphqlConfig + .clientToQuery() + .query(QueryOptions(document: gql('query {}'))); + expect( + response.data, + isNull, + ); + }); + }); +}