TF-2819 calendar event maybe repo implementation
This commit is contained in:
@@ -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<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);
|
||||
}
|
||||
}
|
||||
@@ -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<NotAcceptableCalendarEventException>()));
|
||||
});
|
||||
});
|
||||
|
||||
group('calendar event maybe repository test:', () {
|
||||
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>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user