feat: made GameEvent support value equality

pull/3/head
alestiago 4 years ago
parent 6b0d8b45b2
commit d6fe78df28

@ -1,13 +1,16 @@
part of 'game_bloc.dart';
@immutable
abstract class GameEvent {
abstract class GameEvent extends Equatable {
const GameEvent();
}
/// Event added when a user drops a ball off the screen.
class BallLost extends GameEvent {
const BallLost();
@override
List<Object?> get props => [];
}
/// Event added when a user increases their score.
@ -17,4 +20,7 @@ class Scored extends GameEvent {
}) : assert(points > 0, 'Points must be greater than 0');
final int points;
@override
List<Object?> get props => [points];
}

@ -7,6 +7,10 @@ void main() {
test('can be instantiated', () {
expect(const BallLost(), isNotNull);
});
test('supports value equality', () {
expect(const BallLost(), equals(const BallLost()));
});
});
group('Scored', () {
@ -14,6 +18,10 @@ void main() {
expect(const Scored(points: 1), isNotNull);
});
test('supports value equality', () {
expect(const Scored(points: 1), equals(const Scored(points: 1)));
});
test(
'throws AssertionError '
'when score is smaller than 1', () {

Loading…
Cancel
Save