first widget test for `graphql_flutter` package
MODIFY
.circleci/config.yml
.circleci/config.yml
@@ -101,15 +101,16 @@ jobs:
pub global activate coverage
pub get
pub run test_coverage
- # - run:
- # name: Code coverage (graphql_flutter)
- # command: |
- # cd packages/graphql_flutter
- # flutter test --coverage
+ - run:
+ name: Code coverage (graphql_flutter)
+ command: |
+ cd packages/graphql_flutter
+ flutter test --coverage
- run:
name: Upload coverage
command: |
- bash <(curl -s https://codecov.io/bash)
+ bash <(curl -s https://codecov.io/bash) -F graphql_flutter
+ bash <(curl -s https://codecov.io/bash) -F graphql_client
release:
docker: *node_environment
steps:

ADD
.codecov.yml
+flags:
+ graphql_flutter:
+ paths:
+ - packages/graphql_flutter/
+ graphql_client:
+ paths:
+ - packages/graphql/

MODIFY
packages/graphql_flutter/lib/src/widgets/graphql_consumer.dart
packages/graphql_flutter/lib/src/widgets/graphql_consumer.dart
@@ -17,7 +17,7 @@ class GraphQLConsumer extends StatelessWidget {
@override
Widget build(BuildContext context) {
/// Gets the client from the closest wrapping [GraphQLProvider].
- final GraphQLClient client = GraphQLProvider.of(context).value;
+ final GraphQLClient client = GraphQLProvider.of(context)?.value;
assert(client != null);
return builder(client);

MODIFY
packages/graphql_flutter/lib/src/widgets/graphql_provider.dart
packages/graphql_flutter/lib/src/widgets/graphql_provider.dart
@@ -16,7 +16,7 @@ class GraphQLProvider extends StatefulWidget {
final _InheritedGraphQLProvider inheritedGraphqlProvider =
_InheritedGraphQLProvider.of(context);
- return inheritedGraphqlProvider.client;
+ return inheritedGraphqlProvider?.client;
}
@override

ADD
packages/graphql_flutter/test/graphql_consumer_test.dart
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:graphql_flutter/src/widgets/graphql_consumer.dart'
+ show GraphQLConsumer;
+
+void main() {
+ group('GraphQLConsumer', () {
+ testWidgets('raises assertion error because of lack of GraphQLProvider',
+ (WidgetTester tester) async {
+ await tester.pumpWidget(const GraphQLConsumer(builder: null));
+ expect(tester.takeException(), isAssertionError);
+ });
+ });
+}

first widget test for `graphql_flutter` package