Skip to content

Commit

Permalink
TF-2819 calendar event maybe repo implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora authored and hoangdat committed May 6, 2024
1 parent bbf0521 commit 641c435
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 @@ -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';
Expand All @@ -22,4 +23,9 @@ class CalendarEventRepositoryImpl extends CalendarEventRepository {
Future<CalendarEventAcceptResponse> acceptEventInvitation(AccountId accountId, Set<Id> blobIds) {
return _calendarEventDataSource[DataSourceType.network]!.acceptEventInvitation(accountId, blobIds);
}

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

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

0 comments on commit 641c435

Please sign in to comment.