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

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

Loading…
Cancel
Save