test: fixing tests for BallAdded

pull/213/head
RuiAlonso 3 years ago
parent 8ac7b105c3
commit a05b217925

@ -99,9 +99,6 @@ class _GameBallsController extends ComponentController<PinballGame>
@override @override
bool listenWhen(GameState? previousState, GameState newState) { bool listenWhen(GameState? previousState, GameState newState) {
//final noBallsLeft = component.descendants().whereType<Ball>().isEmpty;
//final canBallRespawn = newState.balls > 0;
final noBallsLeft = newState.balls == 0; final noBallsLeft = newState.balls == 0;
final canBallRespawn = newState.rounds > 0; final canBallRespawn = newState.rounds > 0;
@ -183,15 +180,6 @@ class DebugPinballGame extends PinballGame with FPSCounter, TapDetector {
class _DebugGameBallsController extends _GameBallsController { class _DebugGameBallsController extends _GameBallsController {
_DebugGameBallsController(PinballGame game) : super(game); _DebugGameBallsController(PinballGame game) : super(game);
@override
bool listenWhen(GameState? previousState, GameState newState) {
final noBallsLeft =
component.descendants().whereType<ControlledBall>().isEmpty;
final canBallRespawn = newState.balls > 0;
return noBallsLeft && canBallRespawn;
}
} }
class _DebugInformation extends Component with HasGameRef<DebugPinballGame> { class _DebugInformation extends Component with HasGameRef<DebugPinballGame> {

@ -103,20 +103,20 @@ void main() {
); );
group('controller', () { group('controller', () {
// TODO(alestiago): Write test to be controller agnostic.
group('listenWhen', () {
late GameBloc gameBloc; late GameBloc gameBloc;
setUp(() { setUp(() {
gameBloc = GameBloc(); gameBloc = GameBloc();
}); });
final flameBlocTester = FlameBlocTester<PinballGame, GameBloc>( final flameBlocTester = FlameBlocTester<PinballTestGame, GameBloc>(
gameBuilder: EmptyPinballTestGame.new, gameBuilder: PinballTestGame.new,
blocBuilder: () => gameBloc, blocBuilder: () => gameBloc,
// assets: assets, assets: assets,
); );
// TODO(alestiago): Write test to be controller agnostic.
group('listenWhen', () {
flameBlocTester.testGameWidget( flameBlocTester.testGameWidget(
'listens when all balls are lost and there are more than 0 balls', 'listens when all balls are lost and there are more than 0 balls',
setUp: (game, tester) async { setUp: (game, tester) async {

Loading…
Cancel
Save