diff --git a/lib/features/email/data/repository/calendar_event_repository_impl.dart b/lib/features/email/data/repository/calendar_event_repository_impl.dart index 5e66fb5332..6550bd98e4 100644 --- a/lib/features/email/data/repository/calendar_event_repository_impl.dart +++ b/lib/features/email/data/repository/calendar_event_repository_impl.dart @@ -3,6 +3,7 @@ import 'package:core/data/model/source_type/data_source_type.dart'; import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart'; +import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_response.dart'; import 'package:tmail_ui_user/features/email/data/datasource/calendar_event_datasource.dart'; import 'package:tmail_ui_user/features/email/domain/repository/calendar_event_repository.dart'; import 'package:tmail_ui_user/features/email/presentation/model/blob_calendar_event.dart'; @@ -22,4 +23,9 @@ class CalendarEventRepositoryImpl extends CalendarEventRepository { Future acceptEventInvitation(AccountId accountId, Set blobIds) { return _calendarEventDataSource[DataSourceType.network]!.acceptEventInvitation(accountId, blobIds); } + + @override + Future maybeEventInvitation(AccountId accountId, Set blobIds) { + return _calendarEventDataSource[DataSourceType.network]!.maybeEventInvitation(accountId, blobIds); + } } \ No newline at end of file diff --git a/test/features/email/data/repository/calendar_event_repository_impl_test.dart b/test/features/email/data/repository/calendar_event_repository_impl_test.dart index 09b12d205c..f4626f8224 100644 --- a/test/features/email/data/repository/calendar_event_repository_impl_test.dart +++ b/test/features/email/data/repository/calendar_event_repository_impl_test.dart @@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_id.dart'; import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart'; +import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_response.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:tmail_ui_user/features/email/data/datasource/calendar_event_datasource.dart'; @@ -50,4 +51,34 @@ void main() { throwsA(isA())); }); }); + + group('calendar event maybe repository', () { + final calendarEventMaybeResponse = CalendarEventMaybeResponse( + accountId, + null, + maybe: [EventId(blobId.value)]); + + test('should return response when data source return response', () async { + // arrange + when(calendarEventNetworkDataSource.maybeEventInvitation(any, any)) + .thenAnswer((_) async => calendarEventMaybeResponse); + + // act + final response = await calendarEventRepository.maybeEventInvitation(accountId, {blobId}); + + // assert + expect(response, calendarEventMaybeResponse); + }); + + test('should throw exception when data source throw exception', () { + // arrange + when(calendarEventNetworkDataSource.maybeEventInvitation(any, any)) + .thenThrow(NotMaybeableCalendarEventException()); + + // assert + expect( + () => calendarEventRepository.maybeEventInvitation(accountId, {blobId}), + throwsA(isA())); + }); + }); } \ No newline at end of file