diff --git a/packages/pinball_components/lib/src/components/spaceship_ramp/spaceship_ramp.dart b/packages/pinball_components/lib/src/components/spaceship_ramp/spaceship_ramp.dart index 9f50eff5..3ee380a3 100644 --- a/packages/pinball_components/lib/src/components/spaceship_ramp/spaceship_ramp.dart +++ b/packages/pinball_components/lib/src/components/spaceship_ramp/spaceship_ramp.dart @@ -53,7 +53,7 @@ class SpaceshipRamp extends Component { _SpaceshipRampForegroundRailing(), _SpaceshipRampBase()..initialPosition = Vector2(1.7, -20), _SpaceshipRampBackgroundRailingSpriteComponent(), - _SpaceshipRampArrowSpriteComponent( + SpaceshipRampArrowSpriteComponent( current: bloc.state.hits, ), ...?children, @@ -183,10 +183,11 @@ class _SpaceshipRampBackgroundRampSpriteComponent extends SpriteComponent /// /// Lights progressively whenever a [Ball] gets into [SpaceshipRamp]. /// {@endtemplate} -class _SpaceshipRampArrowSpriteComponent extends SpriteGroupComponent +@visibleForTesting +class SpaceshipRampArrowSpriteComponent extends SpriteGroupComponent with HasGameRef, ParentIsA, ZIndex { /// {@macro spaceship_ramp_arrow_sprite_component} - _SpaceshipRampArrowSpriteComponent({ + SpaceshipRampArrowSpriteComponent({ required int current, }) : super( anchor: Anchor.center, diff --git a/packages/pinball_components/test/src/components/spaceship_ramp/spaceship_ramp_test.dart b/packages/pinball_components/test/src/components/spaceship_ramp/spaceship_ramp_test.dart index fa613677..1c4745dc 100644 --- a/packages/pinball_components/test/src/components/spaceship_ramp/spaceship_ramp_test.dart +++ b/packages/pinball_components/test/src/components/spaceship_ramp/spaceship_ramp_test.dart @@ -52,8 +52,12 @@ void main() { await tester.pump(); + final index = ramp.children + .whereType() + .first + .current; expect( - ramp.children.whereType().first.current, + SpaceshipRampArrowSpriteState.values[index!], SpaceshipRampArrowSpriteState.inactive, ); @@ -76,10 +80,16 @@ void main() { await game.ensureAdd(canvas); ramp.bloc.onBallInside(); + + await game.ready(); await tester.pump(); + final index = ramp.children + .whereType() + .first + .current; expect( - ramp.children.whereType().first.current, + SpaceshipRampArrowSpriteState.values[index!], SpaceshipRampArrowSpriteState.active1, ); @@ -105,10 +115,15 @@ void main() { ..onBallInside() ..onBallInside(); + await game.ready(); await tester.pump(); + final index = ramp.children + .whereType() + .first + .current; expect( - ramp.children.whereType().first.current, + SpaceshipRampArrowSpriteState.values[index!], SpaceshipRampArrowSpriteState.active2, ); @@ -135,10 +150,15 @@ void main() { ..onBallInside() ..onBallInside(); + await game.ready(); await tester.pump(); + final index = ramp.children + .whereType() + .first + .current; expect( - ramp.children.whereType().first.current, + SpaceshipRampArrowSpriteState.values[index!], SpaceshipRampArrowSpriteState.active3, ); @@ -166,10 +186,15 @@ void main() { ..onBallInside() ..onBallInside(); + await game.ready(); await tester.pump(); + final index = ramp.children + .whereType() + .first + .current; expect( - ramp.children.whereType().first.current, + SpaceshipRampArrowSpriteState.values[index!], SpaceshipRampArrowSpriteState.active4, ); @@ -198,10 +223,15 @@ void main() { ..onBallInside() ..onBallInside(); + await game.ready(); await tester.pump(); + final index = ramp.children + .whereType() + .first + .current; expect( - ramp.children.whereType().first.current, + SpaceshipRampArrowSpriteState.values[index!], SpaceshipRampArrowSpriteState.active5, );