From 32dbae67f719e54aba8b808fbeffc8c8fbd17aa5 Mon Sep 17 00:00:00 2001 From: DatDang Date: Mon, 29 Apr 2024 09:46:45 +0700 Subject: [PATCH] TF-2838 calendar event reject repo implementation --- .../calendar_event_repository_impl.dart | 6 ++++ .../calendar_event_repository_impl_test.dart | 31 +++++++++++++++++++ 2 files changed, 37 insertions(+) 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..7149fd2a13 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_reject_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 rejectEventInvitation(AccountId accountId, Set blobIds) { + return _calendarEventDataSource[DataSourceType.network]!.rejectEventInvitation(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..02b56d1e57 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_reject_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 reject repository test:', () { + final calendarEventRejectResponseresponse = CalendarEventRejectResponse( + accountId, + null, + rejected: [EventId(blobId.value)]); + + test('should return response when data source return response', () async { + // arrange + when(calendarEventNetworkDataSource.rejectEventInvitation(any, any)) + .thenAnswer((_) async => calendarEventRejectResponseresponse); + + // act + final response = await calendarEventRepository.rejectEventInvitation(accountId, {blobId}); + + // assert + expect(response, calendarEventRejectResponseresponse); + }); + + test('should throw exception when data source throw exception', () { + // arrange + when(calendarEventNetworkDataSource.rejectEventInvitation(any, any)) + .thenThrow(NotRejectableCalendarEventException()); + + // assert + expect( + () => calendarEventRepository.rejectEventInvitation(accountId, {blobId}), + throwsA(isA())); + }); + }); } \ No newline at end of file