chore: update CharacterSelectionDialog

pull/254/head
arturplaczek 3 years ago
parent 12ce2083b3
commit 52bb7ea119

@ -47,19 +47,7 @@ class CharacterSelectionView extends StatelessWidget {
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
// TODO(arturplaczek): remove after merge StarBlocListener context.read<StartGameBloc>().add(const CharacterSelected());
final height = MediaQuery.of(context).size.height * 0.5;
showDialog<void>(
context: context,
builder: (_) => Center(
child: SizedBox(
height: height,
width: height * 1.4,
child: const HowToPlayDialog(),
),
),
);
}, },
child: Text(l10n.start), child: Text(l10n.start),
), ),

@ -12,9 +12,12 @@ import '../../helpers/helpers.dart';
void main() { void main() {
late CharacterThemeCubit characterThemeCubit; late CharacterThemeCubit characterThemeCubit;
late StartGameBloc startGameBloc;
setUp(() { setUp(() {
characterThemeCubit = MockCharacterThemeCubit(); characterThemeCubit = MockCharacterThemeCubit();
startGameBloc = MockStartGameBloc();
whenListen( whenListen(
characterThemeCubit, characterThemeCubit,
const Stream<CharacterThemeState>.empty(), const Stream<CharacterThemeState>.empty(),
@ -84,17 +87,24 @@ void main() {
.called(1); .called(1);
}); });
testWidgets('displays how to play dialog when start is tapped', testWidgets('calls CharacterSelected event when start is tapped',
(tester) async { (tester) async {
whenListen(
startGameBloc,
Stream.value(const StartGameState.initial()),
initialState: const StartGameState.initial(),
);
await tester.pumpApp( await tester.pumpApp(
CharacterSelectionView(), CharacterSelectionView(),
characterThemeCubit: characterThemeCubit, characterThemeCubit: characterThemeCubit,
startGameBloc: startGameBloc,
); );
await tester.ensureVisible(find.byType(TextButton)); await tester.ensureVisible(find.byType(TextButton));
await tester.tap(find.byType(TextButton)); await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(HowToPlayDialog), findsOneWidget); verify(() => startGameBloc.add(CharacterSelected())).called(1);
}); });
}); });

Loading…
Cancel
Save