test: tests coverage

pull/79/head
RuiAlonso 4 years ago
parent 1284acfdfb
commit 8ffc2d2259

@ -0,0 +1,61 @@
import 'package:flame_forge2d/flame_forge2d.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('Spaceship', () {
late Filter filterData;
late Fixture fixture;
late Body body;
late PinballGame game;
late Ball ball;
late SpaceshipDropHole hole;
setUp(() {
filterData = MockFilter();
fixture = MockFixture();
when(() => fixture.filterData).thenReturn(filterData);
body = MockBody();
when(() => body.fixtures).thenReturn([fixture]);
game = MockPinballGame();
ball = MockBall();
when(() => ball.gameRef).thenReturn(game);
when(() => ball.body).thenReturn(body);
hole = MockSpaceshipDropHole();
});
group('SpaceshipDropHoleBallContactCallback', () {
test('changes the ball priority on contact', () {
when(() => hole.outsideLayer).thenReturn(Layer.board);
SpaceshipDropHoleBallContactCallback().begin(
hole,
ball,
MockContact(),
);
verify(() => ball.priority = 1).called(1);
});
test('re order the game children', () {
when(() => hole.outsideLayer).thenReturn(Layer.board);
SpaceshipDropHoleBallContactCallback().begin(
hole,
ball,
MockContact(),
);
verify(game.reorderChildren).called(1);
});
});
});
}

@ -58,6 +58,8 @@ void main() {
group('SpaceshipHoleBallContactCallback', () {
test('changes the ball priority on contact', () {
when(() => hole.outsideLayer).thenReturn(Layer.board);
SpaceshipHoleBallContactCallback().begin(
hole,
ball,
@ -68,6 +70,8 @@ void main() {
});
test('re order the game children', () {
when(() => hole.outsideLayer).thenReturn(Layer.board);
SpaceshipHoleBallContactCallback().begin(
hole,
ball,

@ -59,3 +59,5 @@ class MockFixture extends Mock implements Fixture {}
class MockSpaceshipEntrance extends Mock implements SpaceshipEntrance {}
class MockSpaceshipHole extends Mock implements SpaceshipHole {}
class MockSpaceshipDropHole extends Mock implements SpaceshipDropHole {}

Loading…
Cancel
Save