Skip to content

Commit

Permalink
feat(SNP-744): update bloc_counter screen and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martynov-alex committed Feb 20, 2024
1 parent 8aea233 commit 9542557
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 24 deletions.
23 changes: 17 additions & 6 deletions example/lib/src/counters/bloc_counter/bloc_counter_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,33 @@ import 'package:surf_widget_test_composer_example/src/counters/bloc_counter/bloc
import 'package:surf_widget_test_composer_example/src/counters/bloc_counter/bloc_counter_event.dart';
import 'package:surf_widget_test_composer_example/src/localization/localizations_x.dart';

class BlocCounterScreen extends StatelessWidget {
final BlocCounterBloc bloc;
class BlocCounterScreen extends StatefulWidget {
const BlocCounterScreen({super.key});

const BlocCounterScreen({required this.bloc, super.key});
@override
State<BlocCounterScreen> createState() => _BlocCounterScreenState();
}

class _BlocCounterScreenState extends State<BlocCounterScreen> {
final bloc = BlocCounterBloc();

@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => bloc,
child: const _BlocCounterView(),
child: const BlocCounterView(),
);
}

@override
void dispose() {
bloc.close();
super.dispose();
}
}

class _BlocCounterView extends StatelessWidget {
const _BlocCounterView();
class BlocCounterView extends StatelessWidget {
const BlocCounterView({super.key});

@override
Widget build(BuildContext context) {
Expand Down
3 changes: 1 addition & 2 deletions example/lib/src/routing/routes/bloc_counter_route.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:go_router/go_router.dart';
import 'package:surf_widget_test_composer_example/src/counters/bloc_counter/bloc_counter_bloc.dart';
import 'package:surf_widget_test_composer_example/src/counters/bloc_counter/bloc_counter_screen.dart';
import 'package:surf_widget_test_composer_example/src/routing/app_router.dart';

final blocCounterRoute = GoRoute(
path: AppRoute.blocCounter.path,
name: AppRoute.blocCounter.name,
builder: (context, state) => BlocCounterScreen(bloc: BlocCounterBloc()),
builder: (context, state) => const BlocCounterScreen(),
);
24 changes: 12 additions & 12 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,34 +197,34 @@ packages:
dependency: transitive
description:
name: custom_lint
sha256: f89ff83efdba7c8996e86bb3bad0b759d58f9b19ae4d0e277a386ddd8b481217
sha256: "445242371d91d2e24bd7b82e3583a2c05610094ba2d0575262484ad889c8f981"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.2"
custom_lint_builder:
dependency: transitive
description:
name: custom_lint_builder
sha256: "9cdd9987feaa6925ec5f98d64de4fbbb5d94248ff77bbf2489366efad6c4baef"
sha256: "3a14687fc71a5e2124a29722106f7b7e67dd5a6d58e33f2859650b46acff1d54"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
custom_lint_core:
dependency: transitive
description:
name: custom_lint_core
sha256: "9003a91409c9f1db6e2e50b4870d1d5e802e5923b25f7261bf3cb3e11ea9d4fb"
sha256: "1e9128e095ad5e0973469bdaac1ead8bfc86c485954c23cf617299de5e6fa029"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
dart_style:
dependency: transitive
description:
name: dart_style
sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55"
url: "https://pub.dev"
source: hosted
version: "2.3.4"
version: "2.3.2"
elementary:
dependency: "direct main"
description:
Expand Down Expand Up @@ -409,10 +409,10 @@ packages:
dependency: transitive
description:
name: js
sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b"
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.6.7"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -725,10 +725,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "14.0.0"
version: "11.10.0"
watcher:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:surf_widget_test_composer/surf_widget_test_composer.dart';
Expand All @@ -11,12 +12,17 @@ class MockBlocCounterBloc extends Mock implements BlocCounterBloc {}
void main() {
const int value = 5;
final mockBloc = MockBlocCounterBloc();
final widget = BlocCounterScreen(bloc: mockBloc);
const widget = BlocCounterView();

/// Generate golden.
testWidget<BlocCounterScreen>(
desc: 'BlocCounterScreen',
widgetBuilder: (context, theme) => widget.build(context),
testWidget<BlocCounterView>(
desc: 'BlocCounterView',
widgetBuilder: (context, theme) => MultiBlocProvider(
providers: [
BlocProvider<BlocCounterBloc>(create: (_) => mockBloc),
],
child: widget,
),

setup: (context, mode) {
when(() => mockBloc.state).thenReturn(value);
Expand Down

0 comments on commit 9542557

Please sign in to comment.