Skip to content

Commit

Permalink
fixup! LA-1352-add recipient when adding and retrieving from local da…
Browse files Browse the repository at this point in the history
…tabase
  • Loading branch information
KhaledNjim committed Nov 7, 2024
1 parent af6f6ee commit 4eeb7e9
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import 'package:dartz/dartz.dart';
import 'package:domain/domain.dart';
import 'package:domain/src/usecases/received/received_share_view_state.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
Expand All @@ -46,19 +45,30 @@ void main() {
group('get_all_received_interactor', () {
late MockReceivedShareRepository receivedShareRepository;
late GetAllReceivedSharesInteractor getAllReceivedSharesInteractor;
late RemoveDeletedReceivedShareFromLocalDatabaseInteractor
removeDeletedReceivedShareFromLocalDatabaseInteractor;


setUp(() {
receivedShareRepository = MockReceivedShareRepository();
getAllReceivedSharesInteractor = GetAllReceivedSharesInteractor(receivedShareRepository);
removeDeletedReceivedShareFromLocalDatabaseInteractor =
RemoveDeletedReceivedShareFromLocalDatabaseInteractor(
receivedShareRepository);
getAllReceivedSharesInteractor = GetAllReceivedSharesInteractor(
receivedShareRepository,
removeDeletedReceivedShareFromLocalDatabaseInteractor);
});

test('get all receives interactor should return success with receive list', () async {
when(receivedShareRepository.getAllReceivedShares()).thenAnswer((_) async => [receivedShare1, receivedShare2]);
when(receivedShareRepository.getAllReceivedShareOffline()).thenAnswer((_) async => []);
when(receivedShareRepository.getReceivedShareOffline(receivedShare1.shareId)).thenAnswer((_) async => null);
when(receivedShareRepository.getReceivedShareOffline(receivedShare2.shareId)).thenAnswer((_) async => null);
when(receivedShareRepository
.getAllReceivedShareOfflineByRecipient(RECIPIENT_1.mail))
.thenAnswer((_) async => [receivedShare1]);

final result = await getAllReceivedSharesInteractor.execute();
final result = await getAllReceivedSharesInteractor.execute(RECIPIENT_1.mail);

result.map((success) => (success as GetAllReceivedShareSuccess).receivedShares)
.fold(
Expand All @@ -71,7 +81,8 @@ void main() {
final exception = Exception();
when(receivedShareRepository.getAllReceivedShares()).thenThrow(exception);

final result = await getAllReceivedSharesInteractor.execute();
final result =
await getAllReceivedSharesInteractor.execute(RECIPIENT_1.mail);

result.fold(
(failure) => expect(failure, isA<GetAllReceivedShareFailure>()),
Expand Down

0 comments on commit 4eeb7e9

Please sign in to comment.