mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mocktail/mocktail.dart';
|
|
import 'package:pinball/game/game.dart';
|
|
import 'package:pinball/select_character/select_character.dart';
|
|
|
|
import '../../../helpers/helpers.dart';
|
|
|
|
void main() {
|
|
group('PlayButtonOverlay', () {
|
|
late PinballGame game;
|
|
late GameFlowController gameFlowController;
|
|
|
|
setUp(() {
|
|
game = MockPinballGame();
|
|
gameFlowController = MockGameFlowController();
|
|
|
|
when(() => game.gameFlowController).thenReturn(gameFlowController);
|
|
when(gameFlowController.start).thenAnswer((_) {});
|
|
});
|
|
|
|
testWidgets('renders correctly', (tester) async {
|
|
await tester.pumpApp(PlayButtonOverlay(game: game));
|
|
|
|
expect(find.text('Play'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('calls gameFlowController.start when taped', (tester) async {
|
|
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 {
|
|
await tester.pumpApp(PlayButtonOverlay(game: game));
|
|
|
|
await tester.tap(find.text('Play'));
|
|
await tester.pump();
|
|
|
|
expect(find.byType(CharacterSelectionDialog), findsOneWidget);
|
|
});
|
|
});
|
|
}
|