mirror of https://github.com/flutter/pinball.git
parent
643fa45839
commit
ffb931e4c2
@ -1,46 +1,42 @@
|
|||||||
|
import 'package:bloc_test/bloc_test.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:mocktail/mocktail.dart';
|
import 'package:mocktail/mocktail.dart';
|
||||||
import 'package:pinball/game/game.dart';
|
import 'package:pinball/game/game.dart';
|
||||||
import 'package:pinball/select_character/select_character.dart';
|
import 'package:pinball/start_game/bloc/start_game_bloc.dart';
|
||||||
|
|
||||||
import '../../../helpers/helpers.dart';
|
import '../../../helpers/helpers.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('PlayButtonOverlay', () {
|
group('PlayButtonOverlay', () {
|
||||||
late PinballGame game;
|
late StartGameBloc startGameBloc;
|
||||||
late GameFlowController gameFlowController;
|
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
game = MockPinballGame();
|
startGameBloc = MockStartGameBloc();
|
||||||
gameFlowController = MockGameFlowController();
|
|
||||||
|
|
||||||
when(() => game.gameFlowController).thenReturn(gameFlowController);
|
whenListen(
|
||||||
when(gameFlowController.start).thenAnswer((_) {});
|
startGameBloc,
|
||||||
|
Stream.value(const StartGameState.initial()),
|
||||||
|
initialState: const StartGameState.initial(),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('renders correctly', (tester) async {
|
testWidgets('renders correctly', (tester) async {
|
||||||
await tester.pumpApp(PlayButtonOverlay(game: game));
|
await tester.pumpApp(const PlayButtonOverlay());
|
||||||
|
|
||||||
expect(find.text('Play'), findsOneWidget);
|
expect(find.text('Play'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('calls gameFlowController.start when taped', (tester) async {
|
testWidgets('calls PlayTapped event to StartGameBloc when taped on play',
|
||||||
await tester.pumpApp(PlayButtonOverlay(game: game));
|
|
||||||
|
|
||||||
await tester.tap(find.text('Play'));
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
verify(gameFlowController.start).called(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('displays CharacterSelectionDialog when tapped',
|
|
||||||
(tester) async {
|
(tester) async {
|
||||||
await tester.pumpApp(PlayButtonOverlay(game: game));
|
await tester.pumpApp(
|
||||||
|
const PlayButtonOverlay(),
|
||||||
|
startGameBloc: startGameBloc,
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(find.text('Play'));
|
await tester.tap(find.text('Play'));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.byType(CharacterSelectionDialog), findsOneWidget);
|
verify(() => startGameBloc.add(const PlayTapped())).called(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue