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.4 KiB
46 lines
1.4 KiB
3 years ago
|
// ignore_for_file: cascade_invocations
|
||
|
|
||
|
import 'package:flame_test/flame_test.dart';
|
||
|
import 'package:flutter_test/flutter_test.dart';
|
||
|
import 'package:mocktail/mocktail.dart';
|
||
|
import 'package:pinball/game/game.dart';
|
||
|
|
||
|
import '../../helpers/helpers.dart';
|
||
|
|
||
|
void main() {
|
||
|
group('SparkyComputerController', () {
|
||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||
|
final flameTester = FlameTester(EmptyPinballGameTest.new);
|
||
|
|
||
|
late ControlledSparkyComputer controlledSparkyComputer;
|
||
|
|
||
|
setUp(() {
|
||
|
controlledSparkyComputer = ControlledSparkyComputer();
|
||
|
});
|
||
|
|
||
|
test('can be instantiated', () {
|
||
|
expect(
|
||
|
SparkyComputerController(controlledSparkyComputer),
|
||
|
isA<SparkyComputerController>(),
|
||
|
);
|
||
|
});
|
||
|
|
||
|
flameTester.testGameWidget(
|
||
|
'SparkyTurboChargeSensorBallContactCallback turbo charges the ball',
|
||
|
setUp: (game, tester) async {
|
||
|
final contackCallback = SparkyTurboChargeSensorBallContactCallback();
|
||
|
final sparkyTurboChargeSensor = MockSparkyTurboChargeSensor();
|
||
|
final ball = MockControlledBall();
|
||
|
final controller = MockBallController();
|
||
|
|
||
|
when(() => ball.controller).thenReturn(controller);
|
||
|
when(controller.turboCharge).thenAnswer((_) async {});
|
||
|
|
||
|
contackCallback.begin(sparkyTurboChargeSensor, ball, MockContact());
|
||
|
|
||
|
verify(() => ball.controller.turboCharge()).called(1);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
|
}
|