Merge branch 'develop' of github.com:GetStream/stream-chat-flutter into fix/message-search-pagination

This commit is contained in:
xsahil03x
2021-09-06 19:37:33 +05:30
98 changed files with 4076 additions and 1006 deletions
@@ -550,14 +550,21 @@ void main() {
final path = '${_getChannelUrl(channelId, channelType)}/show';
when(() => client.post(path)).thenAnswer(
(_) async => successResponse(path, data: <String, dynamic>{}));
when(() => client.post(
path,
data: {},
))
.thenAnswer(
(_) async => successResponse(path, data: <String, dynamic>{}));
final res = await channelApi.showChannel(channelId, channelType);
expect(res, isNotNull);
verify(() => client.post(path)).called(1);
verify(() => client.post(
path,
data: {},
)).called(1);
verifyNoMoreInteractions(client);
});
@@ -605,4 +612,65 @@ void main() {
verify(() => client.post(path, data: {})).called(1);
verifyNoMoreInteractions(client);
});
test('enableSlowdown', () async {
const channelId = 'test-channel-id';
const channelType = 'test-channel-type';
const cooldown = 10;
const set = {
'cooldown': 10,
};
final path = _getChannelUrl(channelId, channelType);
final channelModel = ChannelModel(
id: channelId,
type: channelType,
extraData: set,
);
when(() => client.patch(path, data: {
'set': set,
})).thenAnswer((_) async => successResponse(path, data: {
'channel': channelModel.toJson(),
}));
final res =
await channelApi.enableSlowdown(channelId, channelType, cooldown);
expect(res, isNotNull);
verify(() => client.patch(path, data: {
'set': set,
})).called(1);
verifyNoMoreInteractions(client);
});
test('disableSlowdown', () async {
const channelId = 'test-channel-id';
const channelType = 'test-channel-type';
const unset = ['cooldown'];
final path = _getChannelUrl(channelId, channelType);
final channelModel = ChannelModel(
id: channelId,
type: channelType,
);
when(() => client.patch(path, data: {
'unset': unset,
})).thenAnswer((_) async => successResponse(path, data: {
'channel': channelModel.toJson(),
}));
final res = await channelApi.disableSlowdown(channelId, channelType);
expect(res, isNotNull);
verify(() => client.patch(path, data: {
'unset': unset,
})).called(1);
verifyNoMoreInteractions(client);
});
}
@@ -12,6 +12,7 @@ void main() {
expect(channel.cid, equals('livestream:test'));
expect(channel.extraData['cats'], equals(true));
expect(channel.extraData['fruit'], equals(['bananas', 'apples']));
expect(channel.cooldown, equals(0));
});
test('should serialize to json correctly', () {
@@ -24,7 +25,13 @@ void main() {
expect(
channel.toJson(),
{'id': 'id', 'type': 'type', 'frozen': false, 'name': 'cool'},
{
'id': 'id',
'type': 'type',
'frozen': false,
'cooldown': 0,
'name': 'cool',
},
);
});
@@ -38,7 +45,13 @@ void main() {
expect(
channel.toJson(),
{'id': 'id', 'type': 'type', 'name': 'cool', 'frozen': false},
{
'id': 'id',
'type': 'type',
'frozen': false,
'cooldown': 0,
'name': 'cool',
},
);
});
});
@@ -13,10 +13,11 @@ void main() {
expect(reaction.type, 'wow');
expect(
reaction.user?.toJson(),
User(id: '2de0297c-f3f2-489d-b930-ef77342edccf', extraData: const {
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
'name': 'Daisy Morgan'
}).toJson(),
User(
id: '2de0297c-f3f2-489d-b930-ef77342edccf',
image: 'https://randomuser.me/api/portraits/women/45.jpg',
name: 'Daisy Morgan',
).toJson(),
);
expect(reaction.score, 1);
expect(reaction.userId, '2de0297c-f3f2-489d-b930-ef77342edccf');
@@ -28,11 +29,11 @@ void main() {
messageId: '76cd8c82-b557-4e48-9d12-87995d3a0e04',
createdAt: DateTime.parse('2020-01-28T22:17:31.108742Z'),
type: 'wow',
user:
User(id: '2de0297c-f3f2-489d-b930-ef77342edccf', extraData: const {
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
'name': 'Daisy Morgan'
}),
user: User(
id: '2de0297c-f3f2-489d-b930-ef77342edccf',
image: 'https://randomuser.me/api/portraits/women/45.jpg',
name: 'Daisy Morgan',
),
userId: '2de0297c-f3f2-489d-b930-ef77342edccf',
extraData: {'bananas': 'yes'},
score: 1,
@@ -58,10 +59,11 @@ void main() {
expect(newReaction.type, 'wow');
expect(
newReaction.user?.toJson(),
User(id: '2de0297c-f3f2-489d-b930-ef77342edccf', extraData: const {
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
'name': 'Daisy Morgan',
}).toJson(),
User(
id: '2de0297c-f3f2-489d-b930-ef77342edccf',
image: 'https://randomuser.me/api/portraits/women/45.jpg',
name: 'Daisy Morgan',
).toJson(),
);
expect(newReaction.score, 1);
expect(newReaction.userId, '2de0297c-f3f2-489d-b930-ef77342edccf');