Skip to content

Commit 1a1662c

Browse files
committed
fix: update ExternalContactsSyncBloc tests to mock getAndListen instead of getLocalInfo
1 parent 604e3cd commit 1a1662c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/blocs/external_contacts_sync_bloc_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void main() {
4949
externalContactsRepository = MockExternalContactsRepository();
5050
contactsRepository = MockContactsRepository();
5151

52-
when(() => userRepository.getLocalInfo()).thenAnswer((_) => _testUser);
52+
when(() => userRepository.getAndListen()).thenAnswer((_) => Stream.value(_testUser));
5353
when(() => externalContactsRepository.load()).thenAnswer((_) async {});
5454
when(() => contactsRepository.syncExternalContacts(any())).thenAnswer((_) async {});
5555
});
@@ -116,7 +116,7 @@ void main() {
116116
'emits RefreshFailure if UserRepository fails during update',
117117
build: () {
118118
when(() => externalContactsRepository.contacts()).thenAnswer((_) => Stream.value([_contactOther]));
119-
when(() => userRepository.getLocalInfo()).thenThrow(Exception('User info error'));
119+
when(() => userRepository.getAndListen()).thenAnswer((_) => Stream.error(Exception('User info error')));
120120

121121
return ExternalContactsSyncBloc(
122122
userRepository: userRepository,
@@ -126,7 +126,8 @@ void main() {
126126
},
127127
act: (bloc) => bloc.add(const ExternalContactsSyncStarted()),
128128
skip: 1,
129-
expect: () => [const ExternalContactsSyncRefreshFailure()],
129+
wait: const Duration(seconds: 5),
130+
expect: () => [const ExternalContactsSyncUpdateFailure()],
130131
);
131132
});
132133
}

0 commit comments

Comments
 (0)