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.
46 lines
1.2 KiB
46 lines
1.2 KiB
import 'package:bloc_test/bloc_test.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mocktail/mocktail.dart';
|
|
import 'package:pinball/game/game.dart';
|
|
import 'package:pinball/start_game/bloc/start_game_bloc.dart';
|
|
|
|
import '../../../helpers/helpers.dart';
|
|
|
|
class _MockStartGameBloc extends Mock implements StartGameBloc {}
|
|
|
|
void main() {
|
|
group('PlayButtonOverlay', () {
|
|
late StartGameBloc startGameBloc;
|
|
|
|
setUp(() async {
|
|
await mockFlameImages();
|
|
startGameBloc = _MockStartGameBloc();
|
|
|
|
whenListen(
|
|
startGameBloc,
|
|
Stream.value(const StartGameState.initial()),
|
|
initialState: const StartGameState.initial(),
|
|
);
|
|
});
|
|
|
|
testWidgets('renders correctly', (tester) async {
|
|
await tester.pumpApp(const PlayButtonOverlay());
|
|
|
|
expect(find.text('Play'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('adds PlayTapped event to StartGameBloc when taped',
|
|
(tester) async {
|
|
await tester.pumpApp(
|
|
const PlayButtonOverlay(),
|
|
startGameBloc: startGameBloc,
|
|
);
|
|
|
|
await tester.tap(find.text('Play'));
|
|
await tester.pump();
|
|
|
|
verify(() => startGameBloc.add(const PlayTapped())).called(1);
|
|
});
|
|
});
|
|
}
|