refined IsoChangedEvent tests

This commit is contained in:
Vadim 2023-06-09 14:11:55 +02:00
parent 7706dc743d
commit 8ce3c9e938

View file

@ -147,7 +147,7 @@ void main() {
'`IsoChangedEvent` tests', '`IsoChangedEvent` tests',
() { () {
blocTest<MeteringBloc, MeteringState>( blocTest<MeteringBloc, MeteringState>(
'`IsoChangedEvent` -> success', 'Pick different ISO (ev100 != null)',
build: () => bloc, build: () => bloc,
seed: () => MeteringDataState( seed: () => MeteringDataState(
ev100: 1.0, ev100: 1.0,
@ -167,13 +167,43 @@ void main() {
isA<MeteringDataState>() isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 1.0) .having((state) => state.ev100, 'ev100', 1.0)
.having((state) => state.ev, 'ev', 2.0) .having((state) => state.ev, 'ev', 2.0)
.having((state) => state.film, 'film', Film.values.first)
.having((state) => state.iso, 'iso', const IsoValue(200, StopType.full)) .having((state) => state.iso, 'iso', const IsoValue(200, StopType.full))
.having((state) => state.nd, 'nd', NdValue.values.first)
.having((state) => state.isMetering, 'isMetering', false), .having((state) => state.isMetering, 'isMetering', false),
], ],
); );
blocTest<MeteringBloc, MeteringState>( blocTest<MeteringBloc, MeteringState>(
'`IsoChangedEvent` -> same ISO picked', 'Pick different ISO (ev100 = null)',
build: () => bloc,
seed: () => MeteringDataState(
ev100: null,
film: Film.values[1],
iso: const IsoValue(100, StopType.full),
nd: NdValue.values.first,
isMetering: false,
),
act: (bloc) async {
bloc.add(const IsoChangedEvent(IsoValue(200, StopType.full)));
},
verify: (_) {
verify(() => meteringInteractor.film = Film.values.first).called(1);
verify(() => meteringInteractor.iso = const IsoValue(200, StopType.full)).called(1);
},
expect: () => [
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', null)
.having((state) => state.ev, 'ev', null)
.having((state) => state.film, 'film', Film.values.first)
.having((state) => state.iso, 'iso', const IsoValue(200, StopType.full))
.having((state) => state.nd, 'nd', NdValue.values.first)
.having((state) => state.isMetering, 'isMetering', false),
],
);
blocTest<MeteringBloc, MeteringState>(
'Pick same ISO',
build: () => bloc, build: () => bloc,
seed: () => MeteringDataState( seed: () => MeteringDataState(
ev100: 1.0, ev100: 1.0,
@ -191,13 +221,75 @@ void main() {
}, },
expect: () => [], expect: () => [],
); );
blocTest<MeteringBloc, MeteringState>(
'Pick different ISO & measure',
build: () => bloc,
seed: () => MeteringDataState(
ev100: 1.0,
film: Film.values[1],
iso: const IsoValue(100, StopType.full),
nd: NdValue.values.first,
isMetering: false,
),
act: (bloc) async {
bloc.add(const IsoChangedEvent(IsoValue(200, StopType.full)));
bloc.add(const MeasureEvent());
bloc.onCommunicationState(const communication_states.MeteringEndedState(2));
},
verify: (_) {
verify(() => meteringInteractor.film = Film.values.first).called(1);
verify(() => meteringInteractor.iso = const IsoValue(200, StopType.full)).called(1);
},
expect: () => [
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 1.0)
.having((state) => state.ev, 'ev', 2.0)
.having((state) => state.film, 'film', Film.values.first)
.having((state) => state.iso, 'iso', const IsoValue(200, StopType.full))
.having((state) => state.nd, 'nd', NdValue.values.first)
.having((state) => state.isMetering, 'isMetering', false),
isA<LoadingState>(),
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 2.0)
.having((state) => state.ev, 'ev', 3.0)
.having((state) => state.film, 'film', Film.values.first)
.having((state) => state.iso, 'iso', const IsoValue(200, StopType.full))
.having((state) => state.nd, 'nd', NdValue.values.first)
.having((state) => state.isMetering, 'isMetering', false),
],
);
}, },
); );
group( group(
'`NdChangedEvent` tests', '`NdChangedEvent` tests',
() { () {
// blocTest<MeteringBloc, MeteringState>(
'`NdChangedEvent` -> success',
build: () => bloc,
seed: () => MeteringDataState(
ev100: 1.0,
film: Film.values[1],
iso: const IsoValue(100, StopType.full),
nd: NdValue.values.first,
isMetering: false,
),
act: (bloc) async {
bloc.add(const NdChangedEvent(NdValue(2)));
},
verify: (_) {
verify(() => meteringInteractor.film = Film.values.first).called(1);
verify(() => meteringInteractor.ndFilter = const NdValue(2)).called(1);
},
expect: () => [
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 1.0)
.having((state) => state.ev, 'ev', 2.0)
.having((state) => state.iso, 'iso', const IsoValue(200, StopType.full))
.having((state) => state.isMetering, 'isMetering', false),
],
);
}, },
); );