test: coverage

pull/416/head
RuiAlonso 3 years ago
parent f587911651
commit a3b03976e3

@ -22,6 +22,52 @@ void main() {
); );
}); });
group('onProgressed', () {
blocTest<SpaceshipRampCubit, SpaceshipRampState>(
'emits next arrow lightState',
build: SpaceshipRampCubit.new,
act: (bloc) => bloc
..onProgressed()
..onProgressed()
..onProgressed()
..onProgressed()
..onProgressed()
..onProgressed(),
expect: () => [
isA<SpaceshipRampState>().having(
(state) => state.lightState,
'lightState',
ArrowLightState.active1,
),
isA<SpaceshipRampState>().having(
(state) => state.lightState,
'lightState',
ArrowLightState.active2,
),
isA<SpaceshipRampState>().having(
(state) => state.lightState,
'lightState',
ArrowLightState.active3,
),
isA<SpaceshipRampState>().having(
(state) => state.lightState,
'lightState',
ArrowLightState.active4,
),
isA<SpaceshipRampState>().having(
(state) => state.lightState,
'lightState',
ArrowLightState.active5,
),
isA<SpaceshipRampState>().having(
(state) => state.lightState,
'lightState',
ArrowLightState.inactive,
),
],
);
});
group('onReset', () { group('onReset', () {
blocTest<SpaceshipRampCubit, SpaceshipRampState>( blocTest<SpaceshipRampCubit, SpaceshipRampState>(
'emits state reset to initial values', 'emits state reset to initial values',

@ -30,18 +30,34 @@ void main() {
isNotNull, isNotNull,
); );
}); });
test(
'throws AssertionError '
'when hits is negative',
() {
expect(
() => SpaceshipRampState(
hits: -1,
lightState: ArrowLightState.inactive,
),
throwsAssertionError,
);
},
);
}); });
test( test(
'throws AssertionError ' 'fullArrowLit returns if lightState is last one',
'when hits is negative',
() { () {
expect( expect(
() => SpaceshipRampState( SpaceshipRampState.initial().fullArrowLit,
hits: -1, isFalse,
lightState: ArrowLightState.inactive, );
), expect(
throwsAssertionError, SpaceshipRampState.initial()
.copyWith(lightState: ArrowLightState.active5)
.fullArrowLit,
isTrue,
); );
}, },
); );

Loading…
Cancel
Save