Initial commit: unionflow-mobile-apps
Application Flutter complète (sans build artifacts). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/// Tests unitaires pour CancelRegistration use case
|
||||
library cancel_registration_test;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:unionflow_mobile_apps/features/events/domain/repositories/evenement_repository.dart';
|
||||
import 'package:unionflow_mobile_apps/features/events/domain/usecases/cancel_registration.dart';
|
||||
|
||||
@GenerateMocks([IEvenementRepository])
|
||||
import 'cancel_registration_test.mocks.dart';
|
||||
|
||||
void main() {
|
||||
late CancelRegistration useCase;
|
||||
late MockIEvenementRepository mockRepository;
|
||||
|
||||
setUp(() {
|
||||
mockRepository = MockIEvenementRepository();
|
||||
useCase = CancelRegistration(mockRepository);
|
||||
});
|
||||
|
||||
group('CancelRegistration Use Case', () {
|
||||
const tEventId = 'event123';
|
||||
|
||||
test('should cancel registration successfully', () async {
|
||||
// Arrange
|
||||
when(mockRepository.desinscrireEvenement(tEventId))
|
||||
.thenAnswer((_) async => Future.value());
|
||||
|
||||
// Act
|
||||
await useCase(tEventId);
|
||||
|
||||
// Assert
|
||||
verify(mockRepository.desinscrireEvenement(tEventId));
|
||||
verifyNoMoreInteractions(mockRepository);
|
||||
});
|
||||
|
||||
test('should throw exception when event not found', () async {
|
||||
// Arrange
|
||||
when(mockRepository.desinscrireEvenement(any))
|
||||
.thenThrow(Exception('Événement non trouvé'));
|
||||
|
||||
// Act & Assert
|
||||
expect(() => useCase('nonexistent'), throwsA(isA<Exception>()));
|
||||
});
|
||||
|
||||
test('should throw exception when not registered', () async {
|
||||
// Arrange
|
||||
when(mockRepository.desinscrireEvenement(any))
|
||||
.thenThrow(Exception('Vous n\'êtes pas inscrit à cet événement'));
|
||||
|
||||
// Act & Assert
|
||||
expect(() => useCase(tEventId), throwsA(isA<Exception>()));
|
||||
});
|
||||
|
||||
test('should throw exception when cancellation fails', () async {
|
||||
// Arrange
|
||||
when(mockRepository.desinscrireEvenement(any))
|
||||
.thenThrow(Exception('Erreur de désinscription'));
|
||||
|
||||
// Act & Assert
|
||||
expect(() => useCase(tEventId), throwsException);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user