diff --git a/packages/pinball_components/sandbox/lib/stories/spaceship/basic.dart b/packages/pinball_components/sandbox/lib/stories/spaceship/basic.dart index 53444d61..6f33f444 100644 --- a/packages/pinball_components/sandbox/lib/stories/spaceship/basic.dart +++ b/packages/pinball_components/sandbox/lib/stories/spaceship/basic.dart @@ -24,8 +24,8 @@ class BasicSpaceship extends BasicGame with TapDetector { void onTapUp(TapUpInfo info) { add( Ball(baseColor: Colors.blue) - ..initialPosition = info.eventPosition.game - ..layer = Layer.jetpack, + ..initialPosition = info.eventPosition.game + ..layer = Layer.jetpack, ); } } diff --git a/packages/pinball_components/test/src/components/golden/spaceship.png b/packages/pinball_components/test/src/components/golden/spaceship.png new file mode 100644 index 00000000..579d955f Binary files /dev/null and b/packages/pinball_components/test/src/components/golden/spaceship.png differ diff --git a/packages/pinball_components/test/src/components/spaceship_test.dart b/packages/pinball_components/test/src/components/spaceship_test.dart index 970a25a6..175ed04b 100644 --- a/packages/pinball_components/test/src/components/spaceship_test.dart +++ b/packages/pinball_components/test/src/components/spaceship_test.dart @@ -1,4 +1,9 @@ +// ignore_for_file: cascade_invocations + +import 'package:flame/game.dart'; import 'package:flame_forge2d/flame_forge2d.dart'; +import 'package:flame_test/flame_test.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:pinball_components/pinball_components.dart'; @@ -34,6 +39,25 @@ void main() { hole = MockSpaceshipHole(); }); + group('Spaceship', () { + testWidgets('renders correctly', (tester) async { + final game = TestGame(); + + await tester.runAsync(() async { + await tester.pumpWidget(GameWidget(game: game)); + await game.ready(); + await game.addFromBlueprint(Spaceship(position: Vector2(30, -30))); + await game.ready(); + await tester.pump(); + }); + + await expectLater( + find.byWidgetPredicate((w) => w is GameWidget).first, + matchesGoldenFile('golden/spaceship.png'), + ); + }); + }); + group('SpaceshipEntranceBallContactCallback', () { test('changes the ball priority on contact', () { SpaceshipEntranceBallContactCallback().begin(