Skip to content

Commit

Permalink
TF-2838 calendar event reject repo implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Apr 29, 2024
1 parent e2d7286 commit 32dbae6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -28,4 +29,9 @@ class CalendarEventRepositoryImpl extends CalendarEventRepository {
Future<CalendarEventAcceptResponse> accept(AccountId accountId, Set<Id> blobIds) {
return _calendarEventDataSource[DataSourceType.network]!.accept(accountId, blobIds);
}

@override
Future<CalendarEventRejectResponse> rejectEventInvitation(AccountId accountId, Set<Id> blobIds) {
return _calendarEventDataSource[DataSourceType.network]!.rejectEventInvitation(accountId, blobIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -50,4 +51,34 @@ void main() {
throwsA(isA<NotAcceptableCalendarEventException>()));
});
});

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<NotRejectableCalendarEventException>()));
});
});
}

0 comments on commit 32dbae6

Please sign in to comment.