From aa7d11984acc266699a3722c534246ffece1aa80 Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Fri, 1 Apr 2022 09:19:53 +0200 Subject: [PATCH] test: fixed tests for ball contact with exit rail --- lib/game/components/spaceship_exit_rail.dart | 2 +- test/game/components/spaceship_exit_rail_test.dart | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/game/components/spaceship_exit_rail.dart b/lib/game/components/spaceship_exit_rail.dart index 8c1971ed..fed97e0e 100644 --- a/lib/game/components/spaceship_exit_rail.dart +++ b/lib/game/components/spaceship_exit_rail.dart @@ -217,7 +217,7 @@ class SpaceshipExitRailEndBallContactCallback @override void begin(SpaceshipExitRailEnd exitRail, Ball ball, _) { ball - ..sendTo(1) // TODO(ruimiguel): sendTo board priority + ..sendTo(exitRail.outsidePriority) ..layer = exitRail.outsideLayer; } } diff --git a/test/game/components/spaceship_exit_rail_test.dart b/test/game/components/spaceship_exit_rail_test.dart index 99afc808..dfec8513 100644 --- a/test/game/components/spaceship_exit_rail_test.dart +++ b/test/game/components/spaceship_exit_rail_test.dart @@ -32,28 +32,30 @@ void main() { }); group('SpaceshipExitHoleBallContactCallback', () { - test('changes the ball priority on contact', () { + setUp(() { + when(() => ball.priority).thenReturn(1); when(() => exitRailEnd.outsideLayer).thenReturn(Layer.board); + when(() => exitRailEnd.outsidePriority).thenReturn(0); + }); + test('changes the ball priority on contact', () { SpaceshipExitRailEndBallContactCallback().begin( exitRailEnd, ball, MockContact(), ); - verify(() => ball.priority = 1).called(1); + verify(() => ball.sendTo(exitRailEnd.outsidePriority)).called(1); }); - test('reorders the game children', () { - when(() => exitRailEnd.outsideLayer).thenReturn(Layer.board); - + test('changes the ball layer on contact', () { SpaceshipExitRailEndBallContactCallback().begin( exitRailEnd, ball, MockContact(), ); - verify(game.reorderChildren).called(1); + verify(() => ball.layer = exitRailEnd.outsideLayer).called(1); }); }); });