From a05b217925a98263fbbe9c0e8d3e4f2f6279c713 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Mon, 25 Apr 2022 21:12:19 +0200 Subject: [PATCH] test: fixing tests for BallAdded --- lib/game/pinball_game.dart | 12 ------------ test/game/pinball_game_test.dart | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index cb30fec3..0048225a 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -99,9 +99,6 @@ class _GameBallsController extends ComponentController @override bool listenWhen(GameState? previousState, GameState newState) { - //final noBallsLeft = component.descendants().whereType().isEmpty; - //final canBallRespawn = newState.balls > 0; - final noBallsLeft = newState.balls == 0; final canBallRespawn = newState.rounds > 0; @@ -183,15 +180,6 @@ class DebugPinballGame extends PinballGame with FPSCounter, TapDetector { class _DebugGameBallsController extends _GameBallsController { _DebugGameBallsController(PinballGame game) : super(game); - - @override - bool listenWhen(GameState? previousState, GameState newState) { - final noBallsLeft = - component.descendants().whereType().isEmpty; - final canBallRespawn = newState.balls > 0; - - return noBallsLeft && canBallRespawn; - } } class _DebugInformation extends Component with HasGameRef { diff --git a/test/game/pinball_game_test.dart b/test/game/pinball_game_test.dart index aebb31f9..bd198c2c 100644 --- a/test/game/pinball_game_test.dart +++ b/test/game/pinball_game_test.dart @@ -103,20 +103,20 @@ void main() { ); group('controller', () { - // TODO(alestiago): Write test to be controller agnostic. - group('listenWhen', () { - late GameBloc gameBloc; + late GameBloc gameBloc; - setUp(() { - gameBloc = GameBloc(); - }); + setUp(() { + gameBloc = GameBloc(); + }); - final flameBlocTester = FlameBlocTester( - gameBuilder: EmptyPinballTestGame.new, - blocBuilder: () => gameBloc, - // assets: assets, - ); + final flameBlocTester = FlameBlocTester( + gameBuilder: PinballTestGame.new, + blocBuilder: () => gameBloc, + assets: assets, + ); + // TODO(alestiago): Write test to be controller agnostic. + group('listenWhen', () { flameBlocTester.testGameWidget( 'listens when all balls are lost and there are more than 0 balls', setUp: (game, tester) async {