Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

76% coverage for presentation/core/app_widgets.dart #255

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/presentation/core/app_widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:collaction_app/presentation/core/app_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';

import '../services.dart';

Widget initialWidget = AppWidget();

void main() {
group('Tests for AppWidget build() method', () {
setUp(() {
registerServices();
});
testWidgets('Testing MultiBloc Provider', (tester) async {
await tester.pumpWidget(initialWidget);
final multiBlocProvider = find.byType(MultiBlocProvider);
expect(multiBlocProvider, findsOneWidget);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to check the providers values instance and validate that all the required blocs are provided

});
});
}
14 changes: 14 additions & 0 deletions test/presentation/core/core_fixtures.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:bloc_test/bloc_test.dart';
import 'package:collaction_app/application/auth/auth_bloc.dart';
import 'package:collaction_app/application/crowdaction/subscription/subscription_bloc.dart';
import 'package:collaction_app/application/crowdaction/subscription_status/subscription_status_bloc.dart';

class MockAuthBloc extends MockBloc<AuthEvent, AuthState> implements AuthBloc {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could call this file mocks.dart since it just contains mocks not fixtures

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

I saw some mocks in the test utilities file, they don't belong there.


class MockSubscriptionBloc
extends MockBloc<SubscriptionEvent, SubscriptionState>
implements SubscriptionBloc {}

class MockSubscriptionStatusBloc
extends MockBloc<SubscriptionStatusEvent, SubscriptionStatusState>
implements SubscriptionStatusBloc {}
14 changes: 14 additions & 0 deletions test/presentation/services.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:collaction_app/application/auth/auth_bloc.dart';
import 'package:collaction_app/application/crowdaction/subscription/subscription_bloc.dart';
import 'package:collaction_app/application/crowdaction/subscription_status/subscription_status_bloc.dart';
import 'package:get_it/get_it.dart';

import 'core/core_fixtures.dart';

final getIt = GetIt.instance;

void registerServices() {
getIt.registerSingleton<AuthBloc>(MockAuthBloc());
getIt.registerSingleton<SubscriptionBloc>(MockSubscriptionBloc());
getIt.registerSingleton<SubscriptionStatusBloc>(MockSubscriptionStatusBloc());
}