From 52bb7ea1198146e5dbd6a8228f521725f242033f Mon Sep 17 00:00:00 2001 From: arturplaczek Date: Thu, 28 Apr 2022 12:25:27 +0200 Subject: [PATCH] chore: update CharacterSelectionDialog --- .../view/character_selection_page.dart | 14 +------------- .../view/character_selection_page_test.dart | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/select_character/view/character_selection_page.dart b/lib/select_character/view/character_selection_page.dart index 83dc6ee6..80a184ab 100644 --- a/lib/select_character/view/character_selection_page.dart +++ b/lib/select_character/view/character_selection_page.dart @@ -47,19 +47,7 @@ class CharacterSelectionView extends StatelessWidget { TextButton( onPressed: () { Navigator.of(context).pop(); - // TODO(arturplaczek): remove after merge StarBlocListener - final height = MediaQuery.of(context).size.height * 0.5; - - showDialog( - context: context, - builder: (_) => Center( - child: SizedBox( - height: height, - width: height * 1.4, - child: const HowToPlayDialog(), - ), - ), - ); + context.read().add(const CharacterSelected()); }, child: Text(l10n.start), ), diff --git a/test/select_character/view/character_selection_page_test.dart b/test/select_character/view/character_selection_page_test.dart index 0dda92d7..2debdb3f 100644 --- a/test/select_character/view/character_selection_page_test.dart +++ b/test/select_character/view/character_selection_page_test.dart @@ -12,9 +12,12 @@ import '../../helpers/helpers.dart'; void main() { late CharacterThemeCubit characterThemeCubit; + late StartGameBloc startGameBloc; setUp(() { characterThemeCubit = MockCharacterThemeCubit(); + startGameBloc = MockStartGameBloc(); + whenListen( characterThemeCubit, const Stream.empty(), @@ -84,17 +87,24 @@ void main() { .called(1); }); - testWidgets('displays how to play dialog when start is tapped', + testWidgets('calls CharacterSelected event when start is tapped', (tester) async { + whenListen( + startGameBloc, + Stream.value(const StartGameState.initial()), + initialState: const StartGameState.initial(), + ); + await tester.pumpApp( CharacterSelectionView(), characterThemeCubit: characterThemeCubit, + startGameBloc: startGameBloc, ); await tester.ensureVisible(find.byType(TextButton)); await tester.tap(find.byType(TextButton)); await tester.pumpAndSettle(); - expect(find.byType(HowToPlayDialog), findsOneWidget); + verify(() => startGameBloc.add(CharacterSelected())).called(1); }); });