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

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