@@ -90,6 +90,7 @@ class StreamChatPersistenceClient extends ChatPersistenceClient {
|
||||
'disconnect the previous instance before connecting again.',
|
||||
);
|
||||
}
|
||||
_logger.info('connect');
|
||||
db = databaseProvider?.call(userId, _connectionMode) ??
|
||||
await _defaultDatabaseProvider(userId, _connectionMode);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,15 @@ void main() {
|
||||
expect(client.db, isNull);
|
||||
});
|
||||
|
||||
test('client function throws stateError if db is not yet connected', () {
|
||||
final client = StreamChatPersistenceClient(logLevel: Level.ALL);
|
||||
expect(
|
||||
// Running a function that requires db connection.
|
||||
() => client.getReplies('testParentId'),
|
||||
throwsA(isA<StateError>()),
|
||||
);
|
||||
});
|
||||
|
||||
group('client functions', () {
|
||||
const userId = 'testUserId';
|
||||
final mockDatabase = MockChatDatabase();
|
||||
@@ -66,6 +75,10 @@ void main() {
|
||||
await client.connect(userId, databaseProvider: _mockDatabaseProvider);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await client.disconnect();
|
||||
});
|
||||
|
||||
test('getReplies', () async {
|
||||
const parentId = 'testParentId';
|
||||
final replies = List.generate(3, (index) => Message(id: 'testId$index'));
|
||||
|
||||
Reference in New Issue
Block a user