From 1a39737cf6418c67210dcc3321c24cd8979be39b Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Mon, 9 May 2022 15:53:35 +0200 Subject: [PATCH] test: coverage --- .../spaceship_ramp/spaceship_ramp_test.dart | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) 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 8ca5217a..4c0b0b35 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 @@ -107,15 +107,8 @@ void main() { group('adds', () { flameTester.test('new children', (game) async { - final bloc = _MockSpaceshipRampCubit(); - final streamController = StreamController(); - whenListen( - bloc, - streamController.stream, - initialState: SpaceshipRampState.initial(), - ); final component = Component(); - final ramp = SpaceshipRamp.test(bloc: bloc, children: [component]); + final ramp = SpaceshipRamp(children: [component]); await game.ensureAdd(ramp); expect(ramp.descendants(), contains(component)); @@ -191,4 +184,33 @@ void main() { ); }); }); + + group('SpaceshipRampArrowSpriteComponent', () { + flameTester.test( + 'changes current state ' + 'when SpaceshipRampState changes lightState', + (game) async { + final bloc = _MockSpaceshipRampCubit(); + final state = SpaceshipRampState.initial(); + final streamController = StreamController(); + whenListen( + bloc, + streamController.stream, + initialState: state, + ); + final arrow = SpaceshipRampArrowSpriteComponent(); + final ramp = SpaceshipRamp.test(bloc: bloc, children: [arrow]); + await game.ensureAdd(ramp); + + expect(arrow.current, ArrowLightState.inactive); + + streamController + .add(state.copyWith(lightState: ArrowLightState.active1)); + + await game.ready(); + + expect(arrow.current, ArrowLightState.active1); + }, + ); + }); }