test: added tests for dino walls

pull/115/head
RuiAlonso 4 years ago
parent 1d4e633a21
commit 749013e6bc

@ -14,9 +14,6 @@ class DinoWalls extends Forge2DBlueprint {
/// {@macro dinowalls} /// {@macro dinowalls}
DinoWalls({required this.position}); DinoWalls({required this.position});
/// Total size of the spaceship.
static final size = Vector2(25, 19);
/// The [position] where the elements will be created /// The [position] where the elements will be created
final Vector2 position; final Vector2 position;

@ -0,0 +1,67 @@
// ignore_for_file: cascade_invocations
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:pinball_components/pinball_components.dart';
import '../../helpers/helpers.dart';
void main() {
group('DinoWalls', () {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
flameTester.test(
'loads correctly',
(game) async {
final dinoWalls = DinoWalls(position: Vector2.zero());
await game.addFromBlueprint(dinoWalls);
await game.ready();
for (final wall in dinoWalls.components) {
expect(game.contains(wall), isTrue);
}
},
);
group('DinoTopWall', () {
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.add(
DinoTopWall()..initialPosition = Vector2(0, -50),
);
await game.ready();
await tester.pump();
},
verify: (game, tester) async {
await expectLater(
find.byGame<Forge2DGame>(),
matchesGoldenFile('golden/dino-top-wall.png'),
);
},
);
});
group('DinoBottomWall', () {
flameTester.testGameWidget(
'renders correctly',
setUp: (game, tester) async {
await game.add(
DinoBottomWall()..initialPosition = Vector2(0, -12),
);
await game.ready();
await tester.pump();
},
verify: (game, tester) async {
await expectLater(
find.byGame<Forge2DGame>(),
matchesGoldenFile('golden/dino-bottom-wall.png'),
);
},
);
});
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Loading…
Cancel
Save