feat: Added test

This commit is contained in:
Deven Joshi
2021-02-19 16:24:36 +05:30
parent 6f994c6a3a
commit 8402a6cade
+25 -7
View File
@@ -938,15 +938,33 @@ void main() {
group('channel', () { group('channel', () {
test('should update channel', () async { test('should update channel', () async {
final client = StreamChatClient('test'); final mockDio = MockDio();
when(mockDio.options).thenReturn(BaseOptions());
when(mockDio.interceptors).thenReturn(Interceptors());
final client = StreamChatClient(
'api-key',
httpClient: mockDio,
);
final channelClient = final channelClient =
client.channel('type', id: 'id', extraData: {'name': 'init'}); client.channel('type', id: 'id', extraData: {'name': 'init'});
await channelClient.updatePartial({
'set': { var update = {
'name': 'demo', 'set': {'name': 'demo'}
} };
});
expect(channelClient.extraData['name'], 'demo'); when(mockDio.patch<String>(
'/channels/${channelClient.type}/${channelClient.id}',
data: update,
)).thenAnswer((_) async => Response(data: '{}', statusCode: 200));
await channelClient.updatePartial(update);
verify(mockDio.patch<String>(
'/channels/${channelClient.type}/${channelClient.id}',
data: update))
.called(1);
}); });
}); });
}); });