TF-2859 Unit test add language when reply calendar invitation

This commit is contained in:
DatDang
2024-05-17 16:43:59 +07:00
committed by Dat H. Pham
parent 2e68e7df7d
commit b207880041
6 changed files with 219 additions and 31 deletions
@@ -21,6 +21,7 @@ void main() {
final accountId = AccountId(Id('123'));
final blobId = Id('123321');
final emailId = EmailId(Id('abcde'));
const language = 'en';
group('calendar event accept interactor test:', () {
test('should emit CalendarEventAccepted when repo return data', () {
@@ -29,12 +30,12 @@ void main() {
accountId,
null,
accepted: [EventId(blobId.value)]);
when(calendarEventRepository.acceptEventInvitation(any, any))
when(calendarEventRepository.acceptEventInvitation(any, any, any))
.thenAnswer((_) async => calendarEventAcceptResponse);
// assert
expect(
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId),
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
emitsInOrder([
Right(CalendarEventAccepting()),
Right(CalendarEventAccepted(calendarEventAcceptResponse, emailId))]));
@@ -43,11 +44,11 @@ void main() {
test('should emit CalendarEventAcceptFailure when repo throw exception', () {
// arrange
final exception = NotAcceptableCalendarEventException();
when(calendarEventRepository.acceptEventInvitation(any, any)).thenThrow(exception);
when(calendarEventRepository.acceptEventInvitation(any, any, any)).thenThrow(exception);
// assert
expect(
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId),
acceptCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
emitsInOrder([
Right(CalendarEventAccepting()),
Left(CalendarEventAcceptFailure(exception: exception))]));
@@ -18,6 +18,7 @@ void main() {
final accountId = AccountId(Id('123'));
final blobId = Id('123321');
final emailId = EmailId(Id('abcde'));
const language = 'en';
group('calendar event reject interactor test:', () {
test('should emit CalendarEventRejected when repo return data', () {
@@ -26,12 +27,12 @@ void main() {
accountId,
null,
rejected: [EventId(blobId.value)]);
when(calendarEventRepository.rejectEventInvitation(any, any))
when(calendarEventRepository.rejectEventInvitation(any, any, any))
.thenAnswer((_) async => calendarEventRejectResponse);
// assert
expect(
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId),
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
emitsInOrder([
Right(CalendarEventRejecting()),
Right(CalendarEventRejected(calendarEventRejectResponse, emailId))]));
@@ -40,11 +41,11 @@ void main() {
test('should emit CalendarEventRejectFailure when repo throw exception', () {
// arrange
final exception = NotRejectableCalendarEventException();
when(calendarEventRepository.rejectEventInvitation(any, any)).thenThrow(exception);
when(calendarEventRepository.rejectEventInvitation(any, any, any)).thenThrow(exception);
// assert
expect(
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId),
rejectCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
emitsInOrder([
Right(CalendarEventRejecting()),
Left(CalendarEventRejectFailure(exception: exception))]));
@@ -18,6 +18,7 @@ void main() {
final accountId = AccountId(Id('123'));
final blobId = Id('123321');
final emailId = EmailId(Id('abcde'));
const language = 'en';
group('calendar event maybe interactor should emit expected states', () {
test('when repo return data', () {
@@ -26,12 +27,12 @@ void main() {
accountId,
null,
maybe: [EventId(blobId.value)]);
when(calendarEventRepository.maybeEventInvitation(any, any))
when(calendarEventRepository.maybeEventInvitation(any, any, any))
.thenAnswer((_) async => calendarEventMaybeResponse);
// assert
expect(
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId),
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
emitsInOrder([
Right(CalendarEventMaybeReplying()),
Right(CalendarEventMaybeSuccess(calendarEventMaybeResponse, emailId))]));
@@ -40,11 +41,11 @@ void main() {
test('when repo throw exception', () {
// arrange
final exception = NotMaybeableCalendarEventException();
when(calendarEventRepository.maybeEventInvitation(any, any)).thenThrow(exception);
when(calendarEventRepository.maybeEventInvitation(any, any, any)).thenThrow(exception);
// assert
expect(
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId),
maybeCalendarEventInteractor.execute(accountId, {blobId}, emailId, language),
emitsInOrder([
Right(CalendarEventMaybeReplying()),
Left(CalendarEventMaybeFailure(exception: exception))]));