chore: rename BallCountDisplay to RoundCountDisplay

pull/206/head
arturplaczek 3 years ago
parent a94fb6767c
commit bc85731b62

@ -1,13 +1,15 @@
// ignore_for_file: public_member_api_docs
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
import 'package:pinball/l10n/l10n.dart'; import 'package:pinball/l10n/l10n.dart';
import 'package:pinball/theme/theme.dart'; import 'package:pinball/theme/theme.dart';
class BallCountDisplay extends StatelessWidget { /// {@template round_count_display}
const BallCountDisplay({Key? key}) : super(key: key); /// [Widget] that displays the count of rounds.
/// {@endtemplate}
class RoundCountDisplay extends StatelessWidget {
/// {@macro round_count_display}
const RoundCountDisplay({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -25,9 +27,9 @@ class BallCountDisplay extends StatelessWidget {
const SizedBox(width: 8), const SizedBox(width: 8),
Row( Row(
children: [ children: [
BallIndicator(isActive: balls >= 1), RoundIndicator(isActive: balls >= 1),
BallIndicator(isActive: balls >= 2), RoundIndicator(isActive: balls >= 2),
BallIndicator(isActive: balls >= 3), RoundIndicator(isActive: balls >= 3),
], ],
), ),
], ],
@ -35,13 +37,18 @@ class BallCountDisplay extends StatelessWidget {
} }
} }
/// {@template round_indicator}
/// [Widget] that displays the round indicator.
/// {@endtemplate}
@visibleForTesting @visibleForTesting
class BallIndicator extends StatelessWidget { class RoundIndicator extends StatelessWidget {
const BallIndicator({ /// {@macro round_indicator}
const RoundIndicator({
Key? key, Key? key,
required this.isActive, required this.isActive,
}) : super(key: key); }) : super(key: key);
/// A value that describes whether the indicator is active.
final bool isActive; final bool isActive;
@override @override

@ -7,7 +7,7 @@ import 'package:pinball/theme/app_colors.dart';
import '../../../helpers/helpers.dart'; import '../../../helpers/helpers.dart';
void main() { void main() {
group('ScoreBalls renders', () { group('RoundCountDisplay renders', () {
late GameBloc gameBloc; late GameBloc gameBloc;
const initialState = GameState( const initialState = GameState(
score: 0, score: 0,
@ -27,12 +27,12 @@ void main() {
testWidgets('three active balls', (tester) async { testWidgets('three active balls', (tester) async {
await tester.pumpApp( await tester.pumpApp(
const BallCountDisplay(), const RoundCountDisplay(),
gameBloc: gameBloc, gameBloc: gameBloc,
); );
await tester.pump(); await tester.pump();
expect(find.byType(BallIndicator), findsNWidgets(3)); expect(find.byType(RoundIndicator), findsNWidgets(3));
}); });
testWidgets('two active balls', (tester) async { testWidgets('two active balls', (tester) async {
@ -46,27 +46,27 @@ void main() {
); );
await tester.pumpApp( await tester.pumpApp(
const BallCountDisplay(), const RoundCountDisplay(),
gameBloc: gameBloc, gameBloc: gameBloc,
); );
await tester.pump(); await tester.pump();
expect( expect(
find.byWidgetPredicate( find.byWidgetPredicate(
(widget) => widget is BallIndicator && widget.isActive, (widget) => widget is RoundIndicator && widget.isActive,
), ),
findsNWidgets(2), findsNWidgets(2),
); );
expect( expect(
find.byWidgetPredicate( find.byWidgetPredicate(
(widget) => widget is BallIndicator && !widget.isActive, (widget) => widget is RoundIndicator && !widget.isActive,
), ),
findsOneWidget, findsOneWidget,
); );
}); });
testWidgets('one active balls', (tester) async { testWidgets('one active ball', (tester) async {
final state = initialState.copyWith( final state = initialState.copyWith(
balls: 1, balls: 1,
); );
@ -77,21 +77,21 @@ void main() {
); );
await tester.pumpApp( await tester.pumpApp(
const BallCountDisplay(), const RoundCountDisplay(),
gameBloc: gameBloc, gameBloc: gameBloc,
); );
await tester.pump(); await tester.pump();
expect( expect(
find.byWidgetPredicate( find.byWidgetPredicate(
(widget) => widget is BallIndicator && widget.isActive, (widget) => widget is RoundIndicator && widget.isActive,
), ),
findsOneWidget, findsOneWidget,
); );
expect( expect(
find.byWidgetPredicate( find.byWidgetPredicate(
(widget) => widget is BallIndicator && !widget.isActive, (widget) => widget is RoundIndicator && !widget.isActive,
), ),
findsNWidgets(2), findsNWidgets(2),
); );
@ -101,7 +101,7 @@ void main() {
testWidgets('active score ball is displaying with proper color', testWidgets('active score ball is displaying with proper color',
(tester) async { (tester) async {
await tester.pumpApp( await tester.pumpApp(
const BallIndicator(isActive: true), const RoundIndicator(isActive: true),
); );
await tester.pump(); await tester.pump();
@ -116,7 +116,7 @@ void main() {
testWidgets('inactive score ball is displaying with proper color', testWidgets('inactive score ball is displaying with proper color',
(tester) async { (tester) async {
await tester.pumpApp( await tester.pumpApp(
const BallIndicator(isActive: false), const RoundIndicator(isActive: false),
); );
await tester.pump(); await tester.pump();
Loading…
Cancel
Save