TF-2859 Unit test add language when reply calendar invitation
This commit is contained in:
@@ -0,0 +1,168 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/account/account.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/capability/empty_capability.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
|
import 'package:model/extensions/session_extension.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
final accountId = AccountId(Id('123abc'));
|
||||||
|
|
||||||
|
group('validate calendar event capability test:', () {
|
||||||
|
final account = Account(AccountName('name'), true, true, {});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should return isAvailable is false '
|
||||||
|
'and calendarEventCapability is null '
|
||||||
|
'when there is no such capability',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final session = Session(
|
||||||
|
{},
|
||||||
|
{accountId: account},
|
||||||
|
{}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final result = session.validateCalendarEventCapability(accountId);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(result.isAvailable, false);
|
||||||
|
expect(result.calendarEventCapability, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should return isAvailable is true '
|
||||||
|
'and calendarEventCapability is not null '
|
||||||
|
'when calendar event capability is available',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final calendarEventCapability = CalendarEventCapability();
|
||||||
|
final session = Session(
|
||||||
|
{CapabilityIdentifier.jamesCalendarEvent: calendarEventCapability},
|
||||||
|
{accountId: account},
|
||||||
|
{}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final result = session.validateCalendarEventCapability(AccountId(Id('123abc')));
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(result.isAvailable, true);
|
||||||
|
expect(result.calendarEventCapability, calendarEventCapability);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
group('get language for calendar event test:', () {
|
||||||
|
test(
|
||||||
|
'should return null '
|
||||||
|
'when calendar event capability is not supported',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
const currentLocale = Locale('en', 'US');
|
||||||
|
final session = Session(
|
||||||
|
{CapabilityIdentifier.jamesCalendarEvent: EmptyCapability()},
|
||||||
|
{}, {}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final calendarEventLanguage = session.getLanguageForCalendarEvent(
|
||||||
|
currentLocale,
|
||||||
|
accountId);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(calendarEventLanguage, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should return null '
|
||||||
|
'when calendar event capability supportes no language',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final calendarEventCapability = CalendarEventCapability();
|
||||||
|
const currentLocale = Locale('en', 'US');
|
||||||
|
final session = Session(
|
||||||
|
{CapabilityIdentifier.jamesCalendarEvent: calendarEventCapability},
|
||||||
|
{}, {}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final calendarEventLanguage = session.getLanguageForCalendarEvent(
|
||||||
|
currentLocale,
|
||||||
|
accountId);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(calendarEventLanguage, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should return current locale language '
|
||||||
|
'when calendar event capability supports current locale',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final calendarEventCapability = CalendarEventCapability(
|
||||||
|
replySupportedLanguage: ['en', 'fr'],
|
||||||
|
);
|
||||||
|
const currentLocale = Locale('en', 'US');
|
||||||
|
final session = Session(
|
||||||
|
{CapabilityIdentifier.jamesCalendarEvent: calendarEventCapability},
|
||||||
|
{}, {}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final calendarEventLanguage = session.getLanguageForCalendarEvent(
|
||||||
|
currentLocale,
|
||||||
|
accountId);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(calendarEventLanguage, currentLocale.languageCode);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should return English language '
|
||||||
|
'when calendar event capability doesn\'t support current locale, '
|
||||||
|
'but supports English',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final calendarEventCapability = CalendarEventCapability(
|
||||||
|
replySupportedLanguage: ['en'],
|
||||||
|
);
|
||||||
|
const currentLocale = Locale('fr', 'FR');
|
||||||
|
final session = Session(
|
||||||
|
{CapabilityIdentifier.jamesCalendarEvent: calendarEventCapability},
|
||||||
|
{}, {}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final calendarEventLanguage = session.getLanguageForCalendarEvent(
|
||||||
|
currentLocale,
|
||||||
|
accountId);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(calendarEventLanguage, 'en');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'should return first supported language '
|
||||||
|
'when calendar event capability doesn\'t support both English and current locale',
|
||||||
|
() {
|
||||||
|
// arrange
|
||||||
|
final calendarEventCapability = CalendarEventCapability(
|
||||||
|
replySupportedLanguage: ['vi'],
|
||||||
|
);
|
||||||
|
const currentLocale = Locale('fr', 'FR');
|
||||||
|
final session = Session(
|
||||||
|
{CapabilityIdentifier.jamesCalendarEvent: calendarEventCapability},
|
||||||
|
{}, {}, UserName(''), Uri(), Uri(), Uri(), Uri(), State(''));
|
||||||
|
|
||||||
|
// act
|
||||||
|
final calendarEventLanguage = session.getLanguageForCalendarEvent(
|
||||||
|
currentLocale,
|
||||||
|
accountId);
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(calendarEventLanguage, 'vi');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ void main() {
|
|||||||
final calendarEventRepository = CalendarEventRepositoryImpl(calendarEventDataSource);
|
final calendarEventRepository = CalendarEventRepositoryImpl(calendarEventDataSource);
|
||||||
final accountId = AccountId(Id('123'));
|
final accountId = AccountId(Id('123'));
|
||||||
final blobId = Id('blobId');
|
final blobId = Id('blobId');
|
||||||
|
const language = 'en';
|
||||||
|
|
||||||
group('calendar event repository test:', () {
|
group('calendar event repository test:', () {
|
||||||
final calendarEventAcceptResponseresponse = CalendarEventAcceptResponse(
|
final calendarEventAcceptResponseresponse = CalendarEventAcceptResponse(
|
||||||
@@ -31,11 +32,11 @@ void main() {
|
|||||||
|
|
||||||
test('should return response when data source return response', () async {
|
test('should return response when data source return response', () async {
|
||||||
// arrange
|
// arrange
|
||||||
when(calendarEventNetworkDataSource.acceptEventInvitation(any, any))
|
when(calendarEventNetworkDataSource.acceptEventInvitation(any, any, any))
|
||||||
.thenAnswer((_) async => calendarEventAcceptResponseresponse);
|
.thenAnswer((_) async => calendarEventAcceptResponseresponse);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
final response = await calendarEventRepository.acceptEventInvitation(accountId, {blobId});
|
final response = await calendarEventRepository.acceptEventInvitation(accountId, {blobId}, language);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(response, calendarEventAcceptResponseresponse);
|
expect(response, calendarEventAcceptResponseresponse);
|
||||||
@@ -43,12 +44,12 @@ void main() {
|
|||||||
|
|
||||||
test('should throw exception when data source throw exception', () {
|
test('should throw exception when data source throw exception', () {
|
||||||
// arrange
|
// arrange
|
||||||
when(calendarEventNetworkDataSource.acceptEventInvitation(any, any))
|
when(calendarEventNetworkDataSource.acceptEventInvitation(any, any, any))
|
||||||
.thenThrow(NotAcceptableCalendarEventException());
|
.thenThrow(NotAcceptableCalendarEventException());
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
() => calendarEventRepository.acceptEventInvitation(accountId, {blobId}),
|
() => calendarEventRepository.acceptEventInvitation(accountId, {blobId}, language),
|
||||||
throwsA(isA<NotAcceptableCalendarEventException>()));
|
throwsA(isA<NotAcceptableCalendarEventException>()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -61,11 +62,11 @@ void main() {
|
|||||||
|
|
||||||
test('should return response when data source return response', () async {
|
test('should return response when data source return response', () async {
|
||||||
// arrange
|
// arrange
|
||||||
when(calendarEventNetworkDataSource.maybeEventInvitation(any, any))
|
when(calendarEventNetworkDataSource.maybeEventInvitation(any, any, any))
|
||||||
.thenAnswer((_) async => calendarEventMaybeResponse);
|
.thenAnswer((_) async => calendarEventMaybeResponse);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
final response = await calendarEventRepository.maybeEventInvitation(accountId, {blobId});
|
final response = await calendarEventRepository.maybeEventInvitation(accountId, {blobId}, language);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(response, calendarEventMaybeResponse);
|
expect(response, calendarEventMaybeResponse);
|
||||||
@@ -73,12 +74,12 @@ void main() {
|
|||||||
|
|
||||||
test('should throw exception when data source throw exception', () {
|
test('should throw exception when data source throw exception', () {
|
||||||
// arrange
|
// arrange
|
||||||
when(calendarEventNetworkDataSource.maybeEventInvitation(any, any))
|
when(calendarEventNetworkDataSource.maybeEventInvitation(any, any, any))
|
||||||
.thenThrow(NotMaybeableCalendarEventException());
|
.thenThrow(NotMaybeableCalendarEventException());
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
() => calendarEventRepository.maybeEventInvitation(accountId, {blobId}),
|
() => calendarEventRepository.maybeEventInvitation(accountId, {blobId}, language),
|
||||||
throwsA(isA<NotMaybeableCalendarEventException>()));
|
throwsA(isA<NotMaybeableCalendarEventException>()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -91,11 +92,11 @@ void main() {
|
|||||||
|
|
||||||
test('should return response when data source return response', () async {
|
test('should return response when data source return response', () async {
|
||||||
// arrange
|
// arrange
|
||||||
when(calendarEventNetworkDataSource.rejectEventInvitation(any, any))
|
when(calendarEventNetworkDataSource.rejectEventInvitation(any, any, any))
|
||||||
.thenAnswer((_) async => calendarEventRejectResponseresponse);
|
.thenAnswer((_) async => calendarEventRejectResponseresponse);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
final response = await calendarEventRepository.rejectEventInvitation(accountId, {blobId});
|
final response = await calendarEventRepository.rejectEventInvitation(accountId, {blobId}, language);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(response, calendarEventRejectResponseresponse);
|
expect(response, calendarEventRejectResponseresponse);
|
||||||
@@ -103,12 +104,12 @@ void main() {
|
|||||||
|
|
||||||
test('should throw exception when data source throw exception', () {
|
test('should throw exception when data source throw exception', () {
|
||||||
// arrange
|
// arrange
|
||||||
when(calendarEventNetworkDataSource.rejectEventInvitation(any, any))
|
when(calendarEventNetworkDataSource.rejectEventInvitation(any, any, any))
|
||||||
.thenThrow(NotRejectableCalendarEventException());
|
.thenThrow(NotRejectableCalendarEventException());
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
() => calendarEventRepository.rejectEventInvitation(accountId, {blobId}),
|
() => calendarEventRepository.rejectEventInvitation(accountId, {blobId}, language),
|
||||||
throwsA(isA<NotRejectableCalendarEventException>()));
|
throwsA(isA<NotRejectableCalendarEventException>()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ void main() {
|
|||||||
final accountId = AccountId(Id('123'));
|
final accountId = AccountId(Id('123'));
|
||||||
final blobId = Id('123321');
|
final blobId = Id('123321');
|
||||||
final emailId = EmailId(Id('abcde'));
|
final emailId = EmailId(Id('abcde'));
|
||||||
|
const language = 'en';
|
||||||
|
|
||||||
group('calendar event accept interactor test:', () {
|
group('calendar event accept interactor test:', () {
|
||||||
test('should emit CalendarEventAccepted when repo return data', () {
|
test('should emit CalendarEventAccepted when repo return data', () {
|
||||||
@@ -29,12 +30,12 @@ void main() {
|
|||||||
accountId,
|
accountId,
|
||||||
null,
|
null,
|
||||||
accepted: [EventId(blobId.value)]);
|
accepted: [EventId(blobId.value)]);
|
||||||
when(calendarEventRepository.acceptEventInvitation(any, any))
|
when(calendarEventRepository.acceptEventInvitation(any, any, any))
|
||||||
.thenAnswer((_) async => calendarEventAcceptResponse);
|
.thenAnswer((_) async => calendarEventAcceptResponse);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId),
|
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(CalendarEventAccepting()),
|
Right(CalendarEventAccepting()),
|
||||||
Right(CalendarEventAccepted(calendarEventAcceptResponse, emailId))]));
|
Right(CalendarEventAccepted(calendarEventAcceptResponse, emailId))]));
|
||||||
@@ -43,11 +44,11 @@ void main() {
|
|||||||
test('should emit CalendarEventAcceptFailure when repo throw exception', () {
|
test('should emit CalendarEventAcceptFailure when repo throw exception', () {
|
||||||
// arrange
|
// arrange
|
||||||
final exception = NotAcceptableCalendarEventException();
|
final exception = NotAcceptableCalendarEventException();
|
||||||
when(calendarEventRepository.acceptEventInvitation(any, any)).thenThrow(exception);
|
when(calendarEventRepository.acceptEventInvitation(any, any, any)).thenThrow(exception);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId),
|
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(CalendarEventAccepting()),
|
Right(CalendarEventAccepting()),
|
||||||
Left(CalendarEventAcceptFailure(exception: exception))]));
|
Left(CalendarEventAcceptFailure(exception: exception))]));
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ void main() {
|
|||||||
final accountId = AccountId(Id('123'));
|
final accountId = AccountId(Id('123'));
|
||||||
final blobId = Id('123321');
|
final blobId = Id('123321');
|
||||||
final emailId = EmailId(Id('abcde'));
|
final emailId = EmailId(Id('abcde'));
|
||||||
|
const language = 'en';
|
||||||
|
|
||||||
group('calendar event reject interactor test:', () {
|
group('calendar event reject interactor test:', () {
|
||||||
test('should emit CalendarEventRejected when repo return data', () {
|
test('should emit CalendarEventRejected when repo return data', () {
|
||||||
@@ -26,12 +27,12 @@ void main() {
|
|||||||
accountId,
|
accountId,
|
||||||
null,
|
null,
|
||||||
rejected: [EventId(blobId.value)]);
|
rejected: [EventId(blobId.value)]);
|
||||||
when(calendarEventRepository.rejectEventInvitation(any, any))
|
when(calendarEventRepository.rejectEventInvitation(any, any, any))
|
||||||
.thenAnswer((_) async => calendarEventRejectResponse);
|
.thenAnswer((_) async => calendarEventRejectResponse);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId),
|
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(CalendarEventRejecting()),
|
Right(CalendarEventRejecting()),
|
||||||
Right(CalendarEventRejected(calendarEventRejectResponse, emailId))]));
|
Right(CalendarEventRejected(calendarEventRejectResponse, emailId))]));
|
||||||
@@ -40,11 +41,11 @@ void main() {
|
|||||||
test('should emit CalendarEventRejectFailure when repo throw exception', () {
|
test('should emit CalendarEventRejectFailure when repo throw exception', () {
|
||||||
// arrange
|
// arrange
|
||||||
final exception = NotRejectableCalendarEventException();
|
final exception = NotRejectableCalendarEventException();
|
||||||
when(calendarEventRepository.rejectEventInvitation(any, any)).thenThrow(exception);
|
when(calendarEventRepository.rejectEventInvitation(any, any, any)).thenThrow(exception);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId),
|
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(CalendarEventRejecting()),
|
Right(CalendarEventRejecting()),
|
||||||
Left(CalendarEventRejectFailure(exception: exception))]));
|
Left(CalendarEventRejectFailure(exception: exception))]));
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ void main() {
|
|||||||
final accountId = AccountId(Id('123'));
|
final accountId = AccountId(Id('123'));
|
||||||
final blobId = Id('123321');
|
final blobId = Id('123321');
|
||||||
final emailId = EmailId(Id('abcde'));
|
final emailId = EmailId(Id('abcde'));
|
||||||
|
const language = 'en';
|
||||||
|
|
||||||
group('calendar event maybe interactor should emit expected states', () {
|
group('calendar event maybe interactor should emit expected states', () {
|
||||||
test('when repo return data', () {
|
test('when repo return data', () {
|
||||||
@@ -26,12 +27,12 @@ void main() {
|
|||||||
accountId,
|
accountId,
|
||||||
null,
|
null,
|
||||||
maybe: [EventId(blobId.value)]);
|
maybe: [EventId(blobId.value)]);
|
||||||
when(calendarEventRepository.maybeEventInvitation(any, any))
|
when(calendarEventRepository.maybeEventInvitation(any, any, any))
|
||||||
.thenAnswer((_) async => calendarEventMaybeResponse);
|
.thenAnswer((_) async => calendarEventMaybeResponse);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId),
|
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(CalendarEventMaybeReplying()),
|
Right(CalendarEventMaybeReplying()),
|
||||||
Right(CalendarEventMaybeSuccess(calendarEventMaybeResponse, emailId))]));
|
Right(CalendarEventMaybeSuccess(calendarEventMaybeResponse, emailId))]));
|
||||||
@@ -40,11 +41,11 @@ void main() {
|
|||||||
test('when repo throw exception', () {
|
test('when repo throw exception', () {
|
||||||
// arrange
|
// arrange
|
||||||
final exception = NotMaybeableCalendarEventException();
|
final exception = NotMaybeableCalendarEventException();
|
||||||
when(calendarEventRepository.maybeEventInvitation(any, any)).thenThrow(exception);
|
when(calendarEventRepository.maybeEventInvitation(any, any, any)).thenThrow(exception);
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
expect(
|
expect(
|
||||||
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId),
|
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(CalendarEventMaybeReplying()),
|
Right(CalendarEventMaybeReplying()),
|
||||||
Left(CalendarEventMaybeFailure(exception: exception))]));
|
Left(CalendarEventMaybeFailure(exception: exception))]));
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:dartz/dartz.dart' hide State;
|
import 'package:dartz/dartz.dart' hide State;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@@ -5,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:http_parser/http_parser.dart';
|
import 'package:http_parser/http_parser.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||||
@@ -125,7 +129,11 @@ void main() {
|
|||||||
final testAccountId = AccountId(Id('123'));
|
final testAccountId = AccountId(Id('123'));
|
||||||
final google = Uri.parse('https://www.google.com');
|
final google = Uri.parse('https://www.google.com');
|
||||||
final testSession =
|
final testSession =
|
||||||
Session({}, {}, {}, UserName('data'), google, google, google, google, State('1'));
|
Session({
|
||||||
|
CapabilityIdentifier.jamesCalendarEvent: CalendarEventCapability(
|
||||||
|
replySupportedLanguage: ['en', 'fr'],
|
||||||
|
),
|
||||||
|
}, {}, {}, UserName('data'), google, google, google, google, State('1'));
|
||||||
const testTaskId = 'taskId';
|
const testTaskId = 'taskId';
|
||||||
final testDownloadTaskId = DownloadTaskId(testTaskId);
|
final testDownloadTaskId = DownloadTaskId(testTaskId);
|
||||||
final testBytes = Uint8List(123);
|
final testBytes = Uint8List(123);
|
||||||
@@ -279,6 +287,11 @@ void main() {
|
|||||||
final blobId = Id('abc123');
|
final blobId = Id('abc123');
|
||||||
final emailId = EmailId(Id('xyz123'));
|
final emailId = EmailId(Id('xyz123'));
|
||||||
final calendarEvent = CalendarEvent();
|
final calendarEvent = CalendarEvent();
|
||||||
|
const locale = Locale('en', 'US');
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
Get.locale = locale;
|
||||||
|
});
|
||||||
|
|
||||||
group('accept test:', () {
|
group('accept test:', () {
|
||||||
final acceptCalendarEventInteractor = MockAcceptCalendarEventInteractor();
|
final acceptCalendarEventInteractor = MockAcceptCalendarEventInteractor();
|
||||||
@@ -289,6 +302,7 @@ void main() {
|
|||||||
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
||||||
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
||||||
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
||||||
|
when(mailboxDashboardController.sessionCurrent).thenReturn(testSession);
|
||||||
singleEmailController.onInit();
|
singleEmailController.onInit();
|
||||||
Get.put<AcceptCalendarEventInteractor>(acceptCalendarEventInteractor);
|
Get.put<AcceptCalendarEventInteractor>(acceptCalendarEventInteractor);
|
||||||
mailboxDashboardController.accountId.refresh();
|
mailboxDashboardController.accountId.refresh();
|
||||||
@@ -300,10 +314,10 @@ void main() {
|
|||||||
|
|
||||||
// act
|
// act
|
||||||
singleEmailController.onCalendarEventReplyAction(EventActionType.yes, emailId);
|
singleEmailController.onCalendarEventReplyAction(EventActionType.yes, emailId);
|
||||||
await untilCalled(acceptCalendarEventInteractor.execute(any, any, any));
|
await untilCalled(acceptCalendarEventInteractor.execute(any, any, any, any));
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
verify(acceptCalendarEventInteractor.execute(testAccountId, {blobId}, emailId)).called(1);
|
verify(acceptCalendarEventInteractor.execute(testAccountId, {blobId}, emailId, locale.languageCode)).called(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -316,6 +330,7 @@ void main() {
|
|||||||
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
||||||
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
||||||
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
||||||
|
when(mailboxDashboardController.sessionCurrent).thenReturn(testSession);
|
||||||
singleEmailController.onInit();
|
singleEmailController.onInit();
|
||||||
Get.put<MaybeCalendarEventInteractor>(maybeCalendarEventInteractor);
|
Get.put<MaybeCalendarEventInteractor>(maybeCalendarEventInteractor);
|
||||||
mailboxDashboardController.accountId.refresh();
|
mailboxDashboardController.accountId.refresh();
|
||||||
@@ -327,10 +342,10 @@ void main() {
|
|||||||
|
|
||||||
// act
|
// act
|
||||||
singleEmailController.onCalendarEventReplyAction(EventActionType.maybe, emailId);
|
singleEmailController.onCalendarEventReplyAction(EventActionType.maybe, emailId);
|
||||||
await untilCalled(maybeCalendarEventInteractor.execute(any, any, any));
|
await untilCalled(maybeCalendarEventInteractor.execute(any, any, any, any));
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
verify(maybeCalendarEventInteractor.execute(testAccountId, {blobId}, emailId)).called(1);
|
verify(maybeCalendarEventInteractor.execute(testAccountId, {blobId}, emailId, locale.languageCode)).called(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -343,6 +358,7 @@ void main() {
|
|||||||
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
||||||
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
||||||
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
||||||
|
when(mailboxDashboardController.sessionCurrent).thenReturn(testSession);
|
||||||
singleEmailController.onInit();
|
singleEmailController.onInit();
|
||||||
Get.put<RejectCalendarEventInteractor>(rejectCalendarEventInteractor);
|
Get.put<RejectCalendarEventInteractor>(rejectCalendarEventInteractor);
|
||||||
mailboxDashboardController.accountId.refresh();
|
mailboxDashboardController.accountId.refresh();
|
||||||
@@ -354,10 +370,10 @@ void main() {
|
|||||||
|
|
||||||
// act
|
// act
|
||||||
singleEmailController.onCalendarEventReplyAction(EventActionType.no, emailId);
|
singleEmailController.onCalendarEventReplyAction(EventActionType.no, emailId);
|
||||||
await untilCalled(rejectCalendarEventInteractor.execute(any, any, any));
|
await untilCalled(rejectCalendarEventInteractor.execute(any, any, any, any));
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
verify(rejectCalendarEventInteractor.execute(testAccountId, {blobId}, emailId)).called(1);
|
verify(rejectCalendarEventInteractor.execute(testAccountId, {blobId}, emailId, locale.languageCode)).called(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user