feat: Introduce comprehensive unit tests for models and BLoCs using mockito and bloc_test, and refine TripBloc error handling.
Some checks failed
Deploy to Play Store / build_and_deploy (push) Has been cancelled
Some checks failed
Deploy to Play Store / build_and_deploy (push) Has been cancelled
This commit is contained in:
@@ -103,7 +103,12 @@ class TripBloc extends Bloc<TripEvent, TripState> {
|
||||
'Error loading trips: $error',
|
||||
stackTrace,
|
||||
);
|
||||
emit(const TripError('Impossible de charger les voyages'));
|
||||
add(
|
||||
const _TripsUpdated(
|
||||
[],
|
||||
error: 'Impossible de charger les voyages',
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -117,7 +122,11 @@ class TripBloc extends Bloc<TripEvent, TripState> {
|
||||
/// [event]: The _TripsUpdated event containing the updated trip list
|
||||
/// [emit]: State emitter function
|
||||
void _onTripsUpdated(_TripsUpdated event, Emitter<TripState> emit) {
|
||||
emit(TripLoaded(event.trips));
|
||||
if (event.error != null) {
|
||||
emit(TripError(event.error!));
|
||||
} else {
|
||||
emit(TripLoaded(event.trips));
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles [TripCreateRequested] events.
|
||||
@@ -234,16 +243,11 @@ class TripBloc extends Bloc<TripEvent, TripState> {
|
||||
///
|
||||
/// This internal event is used to process updates from the trip stream
|
||||
/// subscription and emit appropriate states based on the received data.
|
||||
/// internal event
|
||||
class _TripsUpdated extends TripEvent {
|
||||
/// List of trips received from the stream
|
||||
final List<Trip> trips;
|
||||
|
||||
/// Creates a _TripsUpdated event.
|
||||
///
|
||||
/// Args:
|
||||
/// [trips]: List of trips from the stream update
|
||||
const _TripsUpdated(this.trips);
|
||||
|
||||
final String? error;
|
||||
const _TripsUpdated(this.trips, {this.error});
|
||||
@override
|
||||
List<Object?> get props => [trips];
|
||||
List<Object?> get props => [trips, error];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user