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 8799b12217..e50c7355ef 100644 --- a/lib/features/email/data/repository/calendar_event_repository_impl.dart +++ b/lib/features/email/data/repository/calendar_event_repository_impl.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/calendar_event.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/model/event_action.dart'; import 'package:tmail_ui_user/features/email/domain/repository/calendar_event_repository.dart'; @@ -28,4 +29,9 @@ class CalendarEventRepositoryImpl extends CalendarEventRepository { Future accept(AccountId accountId, Set blobIds) { return _calendarEventDataSource[DataSourceType.network]!.accept(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 aa2374e187..612dbce605 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'; @@ -21,7 +22,7 @@ void main() { final accountId = AccountId(Id('123')); final blobId = Id('blobId'); - group('calendar event repository', () { + group('calendar event accept repository', () { final calendarEventAcceptResponseresponse = CalendarEventAcceptResponse( accountId, null, @@ -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