|
|
|
@ -14,16 +14,18 @@ import '../../helpers/helpers.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
final flameTester = FlameTester(PinballGameTest.create);
|
|
|
|
|
final flameTester = FlameTester(EmptyPinballGameTest.new);
|
|
|
|
|
|
|
|
|
|
group('BonusWord', () {
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'loads the letters correctly',
|
|
|
|
|
(game) async {
|
|
|
|
|
await game.ready();
|
|
|
|
|
final bonusWord = BonusWord(
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(bonusWord);
|
|
|
|
|
|
|
|
|
|
final bonusWord = game.children.whereType<BonusWord>().first;
|
|
|
|
|
final letters = bonusWord.children.whereType<BonusLetter>();
|
|
|
|
|
final letters = bonusWord.descendants().whereType<BonusLetter>();
|
|
|
|
|
expect(letters.length, equals(GameBloc.bonusWord.length));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
@ -135,7 +137,7 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('BonusLetter', () {
|
|
|
|
|
final flameTester = FlameTester(PinballGameTest.create);
|
|
|
|
|
final flameTester = FlameTester(EmptyPinballGameTest.new);
|
|
|
|
|
|
|
|
|
|
flameTester.test(
|
|
|
|
|
'loads correctly',
|
|
|
|
@ -215,8 +217,7 @@ void main() {
|
|
|
|
|
late PinballAudio pinballAudio;
|
|
|
|
|
|
|
|
|
|
final flameBlocTester = FlameBlocTester<PinballGame, GameBloc>(
|
|
|
|
|
// TODO(alestiago): Use TestGame once BonusLetter has controller.
|
|
|
|
|
gameBuilder: PinballGameTest.create,
|
|
|
|
|
gameBuilder: EmptyPinballGameTest.new,
|
|
|
|
|
blocBuilder: () => gameBloc,
|
|
|
|
|
repositories: () => [
|
|
|
|
|
RepositoryProvider<PinballAudio>.value(value: pinballAudio),
|
|
|
|
@ -238,14 +239,20 @@ void main() {
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'adds BonusLetterActivated to GameBloc when not activated',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.ready();
|
|
|
|
|
final bonusLetter = game.descendants().whereType<BonusLetter>().first;
|
|
|
|
|
final bonusWord = BonusWord(
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(bonusWord);
|
|
|
|
|
|
|
|
|
|
final bonusLetters =
|
|
|
|
|
game.descendants().whereType<BonusLetter>().toList();
|
|
|
|
|
for (var index = 0; index < bonusLetters.length; index++) {
|
|
|
|
|
final bonusLetter = bonusLetters[index];
|
|
|
|
|
bonusLetter.activate();
|
|
|
|
|
await game.ready();
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
verify(() => gameBloc.add(const BonusLetterActivated(0))).called(1);
|
|
|
|
|
|
|
|
|
|
verify(() => gameBloc.add(BonusLetterActivated(index))).called(1);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -309,25 +316,33 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
flameBlocTester.testGameWidget(
|
|
|
|
|
'only listens when there is a change on the letter status',
|
|
|
|
|
'listens when there is a change on the letter status',
|
|
|
|
|
setUp: (game, tester) async {
|
|
|
|
|
await game.ready();
|
|
|
|
|
final bonusLetter = game.descendants().whereType<BonusLetter>().first;
|
|
|
|
|
final bonusWord = BonusWord(
|
|
|
|
|
position: Vector2.zero(),
|
|
|
|
|
);
|
|
|
|
|
await game.ensureAdd(bonusWord);
|
|
|
|
|
|
|
|
|
|
final bonusLetters =
|
|
|
|
|
game.descendants().whereType<BonusLetter>().toList();
|
|
|
|
|
for (var index = 0; index < bonusLetters.length; index++) {
|
|
|
|
|
final bonusLetter = bonusLetters[index];
|
|
|
|
|
bonusLetter.activate();
|
|
|
|
|
},
|
|
|
|
|
verify: (game, tester) async {
|
|
|
|
|
const state = GameState(
|
|
|
|
|
await game.ready();
|
|
|
|
|
|
|
|
|
|
final state = GameState(
|
|
|
|
|
score: 0,
|
|
|
|
|
balls: 2,
|
|
|
|
|
activatedBonusLetters: [0],
|
|
|
|
|
activatedDashNests: {},
|
|
|
|
|
bonusHistory: [],
|
|
|
|
|
activatedBonusLetters: [index],
|
|
|
|
|
activatedDashNests: const {},
|
|
|
|
|
bonusHistory: const [],
|
|
|
|
|
);
|
|
|
|
|
final bonusLetter = game.descendants().whereType<BonusLetter>().first;
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
bonusLetter.listenWhen(const GameState.initial(), state),
|
|
|
|
|
isTrue,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|