test: coverage

pull/416/head
RuiAlonso 3 years ago
parent 3f6f165c46
commit 1a39737cf6

@ -107,15 +107,8 @@ void main() {
group('adds', () { group('adds', () {
flameTester.test('new children', (game) async { flameTester.test('new children', (game) async {
final bloc = _MockSpaceshipRampCubit();
final streamController = StreamController<SpaceshipRampState>();
whenListen(
bloc,
streamController.stream,
initialState: SpaceshipRampState.initial(),
);
final component = Component(); final component = Component();
final ramp = SpaceshipRamp.test(bloc: bloc, children: [component]); final ramp = SpaceshipRamp(children: [component]);
await game.ensureAdd(ramp); await game.ensureAdd(ramp);
expect(ramp.descendants(), contains(component)); 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<SpaceshipRampState>();
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);
},
);
});
} }

Loading…
Cancel
Save