From cc7231d370f5d5e34ec1d1de48320f2fa6b41cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Adasiewicz?= Date: Fri, 16 Dec 2022 15:08:40 +0100 Subject: [PATCH] fix tests --- packages/stream_chat/test/src/client/client_test.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat/test/src/client/client_test.dart b/packages/stream_chat/test/src/client/client_test.dart index bc6ff843..5389564b 100644 --- a/packages/stream_chat/test/src/client/client_test.dart +++ b/packages/stream_chat/test/src/client/client_test.dart @@ -516,6 +516,9 @@ void main() { }); setUp(() async { + when(() => persistence.updateLastSyncAt(any())) + .thenAnswer((_) => Future.value()); + when(persistence.getLastSyncAt).thenAnswer((_) async => null); client = StreamChatClient(apiKey, chatApi: api, ws: ws) ..chatPersistenceClient = persistence; await client.connectUser(user, token); @@ -532,9 +535,11 @@ void main() { test( '''should update persistence connectionInfo and lastSync when sync succeeds''', () async { + // persistence.updateLastSyncAt might be called when connecting the user. + // Resetting the logs so we start counting invocations correctly. + reset(persistence); const cids = ['test-cid-1', 'test-cid-2', 'test-cid-3']; final lastSyncAt = DateTime.now(); - when(() => api.general.sync(cids, lastSyncAt)) .thenAnswer((_) async => SyncResponse() ..events = [ @@ -567,6 +572,9 @@ void main() { test( 'should work fine if persistence contains sync params', () async { + // persistence.updateLastSyncAt might be called when connecting the user. + // Resetting the logs so we start counting invocations correctly. + reset(persistence); const cids = ['test-cid-1', 'test-cid-2', 'test-cid-3']; final lastSyncAt = DateTime.now();