fixed CameraContainerBloc tests

This commit is contained in:
Vadim 2023-07-09 13:33:58 +02:00
parent 6b645c0ff2
commit 83476a5036
2 changed files with 26 additions and 1 deletions

View file

@ -159,7 +159,8 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
}
Future<void> _onDeinitialize(DeinitializeEvent _, Emitter emit) async {
emit(const CameraLoadingState());
emit(const CameraInitState());
communicationBloc.add(communication_event.MeteringEndedEvent(_ev100));
await _cameraController?.dispose().then((_) => _cameraController = null);
}

View file

@ -310,6 +310,30 @@ void main() {
},
expect: () => [
...initializedStateSequence,
const CameraInitState(),
...initializedStateSequence,
],
);
blocTest<CameraContainerBloc, CameraContainerState>(
'onCommunicationState',
setUp: () {
when(() => meteringInteractor.checkCameraPermission()).thenAnswer((_) async => true);
},
build: () => bloc,
act: (bloc) async {
bloc.add(const InitializeEvent());
await Future.delayed(Duration.zero);
bloc.onCommunicationState(const communication_states.SettingsOpenedState());
await Future.delayed(Duration.zero);
bloc.onCommunicationState(const communication_states.SettingsClosedState());
},
verify: (_) {
verify(() => meteringInteractor.checkCameraPermission()).called(2);
},
expect: () => [
...initializedStateSequence,
const CameraInitState(),
...initializedStateSequence,
],
);