feat: tested bloc

pull/151/head
alestiago 4 years ago
parent b699e7a15d
commit 16f86eb4aa

@ -15,9 +15,7 @@ void main() {
'decreases number of balls', 'decreases number of balls',
build: GameBloc.new, build: GameBloc.new,
act: (bloc) { act: (bloc) {
for (var i = 0; i < bloc.state.balls; i++) { bloc.add(const BallLost());
bloc.add(const BallLost());
}
}, },
expect: () => [ expect: () => [
const GameState( const GameState(
@ -28,21 +26,37 @@ void main() {
activatedDashNests: {}, activatedDashNests: {},
bonusHistory: [], bonusHistory: [],
), ),
],
);
});
group('BonusLostBall', () {
blocTest<GameBloc, GameState>(
'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( const GameState(
score: 0, score: 0,
balls: 1, balls: 3,
bonusBalls: 0, bonusBalls: 1,
activatedBonusLetters: [], activatedBonusLetters: [],
activatedDashNests: {}, activatedDashNests: {},
bonusHistory: [], bonusHistory: [GameBonus.dashNest],
), ),
const GameState( const GameState(
score: 0, score: 0,
balls: 0, balls: 3,
bonusBalls: 0, bonusBalls: 0,
activatedBonusLetters: [], activatedBonusLetters: [],
activatedDashNests: {}, activatedDashNests: {},
bonusHistory: [], bonusHistory: [GameBonus.dashNest],
), ),
], ],
); );

@ -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', () { group('Scored', () {
test('can be instantiated', () { test('can be instantiated', () {
expect(const Scored(points: 1), isNotNull); expect(const Scored(points: 1), isNotNull);

Loading…
Cancel
Save