add event tests

This commit is contained in:
Salvatore Giordano
2021-06-17 10:34:53 +02:00
parent 91907639ad
commit 907573dab1
6 changed files with 176 additions and 34 deletions
+99
View File
@@ -0,0 +1,99 @@
{
"id": "!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU",
"type": "messaging",
"cid": "messaging:!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU",
"last_message_at": "2020-12-02T04:22:16.755334Z",
"created_at": "2020-10-01T08:49:32.90162Z",
"updated_at": "2021-06-17T08:18:48.188996Z",
"created_by": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-17T08:12:05.062115Z",
"banned": false,
"online": true,
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0,
"username": "Rioland"
},
"frozen": false,
"disabled": false,
"members": [
{
"user_id": "super-band-9",
"user": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-17T08:12:05.062115Z",
"banned": false,
"online": true,
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0,
"username": "Rioland"
},
"role": "owner",
"created_at": "2020-10-01T08:49:32.905052Z",
"updated_at": "2020-10-01T08:49:32.905052Z",
"banned": false,
"shadow_banned": false
},
{
"user_id": "cc48de8e-b2db-48e7-bba5-c03cefd61430",
"user": {
"id": "cc48de8e-b2db-48e7-bba5-c03cefd61430",
"role": "user",
"created_at": "2020-07-22T14:59:38.026809Z",
"updated_at": "2020-07-22T14:59:38.31338Z",
"banned": false,
"online": false,
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjA3NjYzMzE1MV5BMl5BanBnXkFtZTgwNTA4NDY4OTE@._V1_UX172_CR0,0,172,256_AL_.jpg",
"name": "Ana De Armas"
},
"role": "member",
"created_at": "2020-10-01T08:49:32.905053Z",
"updated_at": "2020-10-01T08:49:32.905053Z",
"banned": false,
"shadow_banned": false
}
],
"member_count": 2,
"config": {
"created_at": "2020-04-15T14:57:17.00966Z",
"updated_at": "2021-05-25T14:25:30.405621Z",
"name": "messaging",
"typing_events": true,
"read_events": true,
"connect_events": true,
"search": true,
"reactions": true,
"replies": true,
"mutes": true,
"uploads": true,
"url_enrichment": true,
"custom_events": false,
"push_notifications": true,
"message_retention": "infinite",
"max_message_length": 5000,
"automod": "disabled",
"automod_behavior": "flag",
"blocklist": "profanity_en_2020_v1",
"blocklist_behavior": "block",
"automod_thresholds": {},
"commands": [
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]",
"set": "fun_set"
}
]
},
"name": "test"
}
@@ -54,5 +54,53 @@ void main() {
},
);
});
test('copyWith', () {
final event = Event.fromJson(jsonFixture('event.json'));
var newEvent = event.copyWith();
expect(newEvent.type, 'type');
expect(newEvent.cid, 'cid');
expect(newEvent.connectionId, 'connectionId');
expect(newEvent.createdAt, isA<DateTime>());
expect(newEvent.me, isA<OwnUser>());
expect(newEvent.user, isA<User>());
expect(newEvent.isLocal, false);
newEvent = event.copyWith(
type: 'test',
cid: 'test',
connectionId: 'test',
extraData: {},
user: User(id: 'test'),
channelId: 'test',
totalUnreadCount: 2,
channelType: 'testtype',
);
expect(newEvent.channelType, 'testtype');
expect(newEvent.totalUnreadCount, 2);
expect(newEvent.type, 'test');
expect(newEvent.channelId, 'test');
expect(newEvent.cid, 'test');
expect(newEvent.connectionId, 'test');
expect(newEvent.extraData, {});
expect(newEvent.user!.id, 'test');
});
group('eventChannel', () {
test('should parse json correctly', () {
final eventChannel =
EventChannel.fromJson(jsonFixture('event_channel.json'));
expect(eventChannel.type, 'messaging');
expect(eventChannel.cid,
'messaging:!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU');
expect(eventChannel.createdBy!.id, 'super-band-9');
expect(eventChannel.frozen, false);
expect(eventChannel.members!.length, 2);
expect(eventChannel.memberCount, 2);
expect(eventChannel.config, isA<ChannelConfig>());
expect(eventChannel.name, 'test');
});
});
});
}