From 16f86eb4aa15e102a4ecdfb6c3c9a72d73e851e1 Mon Sep 17 00:00:00 2001 From: alestiago Date: Wed, 6 Apr 2022 09:45:57 +0100 Subject: [PATCH] feat: tested bloc --- test/game/bloc/game_bloc_test.dart | 30 +++++++++++++++++++++-------- test/game/bloc/game_event_test.dart | 13 +++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/test/game/bloc/game_bloc_test.dart b/test/game/bloc/game_bloc_test.dart index 470e146e..ec950e5d 100644 --- a/test/game/bloc/game_bloc_test.dart +++ b/test/game/bloc/game_bloc_test.dart @@ -15,9 +15,7 @@ void main() { 'decreases number of balls', build: GameBloc.new, act: (bloc) { - for (var i = 0; i < bloc.state.balls; i++) { - bloc.add(const BallLost()); - } + bloc.add(const BallLost()); }, expect: () => [ const GameState( @@ -28,21 +26,37 @@ void main() { activatedDashNests: {}, bonusHistory: [], ), + ], + ); + }); + + group('BonusLostBall', () { + blocTest( + 'decreases number of balls', + build: GameBloc.new, + act: (bloc) { + for (var i = 0; i < 3; i++) { + bloc.add(DashNestActivated('$i')); + } + bloc.add(const BonusBallLost()); + }, + skip: 2, + expect: () => [ const GameState( score: 0, - balls: 1, - bonusBalls: 0, + balls: 3, + bonusBalls: 1, activatedBonusLetters: [], activatedDashNests: {}, - bonusHistory: [], + bonusHistory: [GameBonus.dashNest], ), const GameState( score: 0, - balls: 0, + balls: 3, bonusBalls: 0, activatedBonusLetters: [], activatedDashNests: {}, - bonusHistory: [], + bonusHistory: [GameBonus.dashNest], ), ], ); diff --git a/test/game/bloc/game_event_test.dart b/test/game/bloc/game_event_test.dart index af9f6148..bff0b240 100644 --- a/test/game/bloc/game_event_test.dart +++ b/test/game/bloc/game_event_test.dart @@ -18,6 +18,19 @@ void main() { }); }); + group('BonusBallLost', () { + test('can be instantiated', () { + expect(const BonusBallLost(), isNotNull); + }); + + test('supports value equality', () { + expect( + BonusBallLost(), + equals(const BonusBallLost()), + ); + }); + }); + group('Scored', () { test('can be instantiated', () { expect(const Scored(points: 1), isNotNull);