From 40c899e7808e4502e8c22acd8c8d84fa1804d02b Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Fri, 18 Mar 2022 17:32:08 +0100 Subject: [PATCH] test: coverage for test isEnabled --- lib/game/components/bonus_word.dart | 3 ++- test/game/components/bonus_word_test.dart | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/game/components/bonus_word.dart b/lib/game/components/bonus_word.dart index 65c8c0d5..c4f6a7fd 100644 --- a/lib/game/components/bonus_word.dart +++ b/lib/game/components/bonus_word.dart @@ -116,7 +116,8 @@ class BonusLetter extends BodyComponent final int _index; /// Indicates if [BonusLetter] could be activated on contact with [Ball]. - /// Deactivated during animation of [GameBonus.word]. + /// Deactivated during animation of [GameBonus.word] and reactivated once + /// animation is finished. bool isEnabled = true; @override diff --git a/test/game/components/bonus_word_test.dart b/test/game/components/bonus_word_test.dart index a9af305e..e5bba7eb 100644 --- a/test/game/components/bonus_word_test.dart +++ b/test/game/components/bonus_word_test.dart @@ -300,12 +300,26 @@ void main() { test('calls ball.activate', () { final ball = MockBall(); final bonusLetter = MockBonusLetter(); - final contactCallback = BonusLetterBallContactCallback(); + + when(() => bonusLetter.isEnabled).thenReturn(true); + contactCallback.begin(ball, bonusLetter, MockContact()); verify(bonusLetter.activate).called(1); }); + + test('do not call ball.activate when letter is disabled', () { + final ball = MockBall(); + final bonusLetter = MockBonusLetter(); + final contactCallback = BonusLetterBallContactCallback(); + + when(() => bonusLetter.isEnabled).thenReturn(false); + + contactCallback.begin(ball, bonusLetter, MockContact()); + + verifyNever(bonusLetter.activate); + }); }); }); }