add OwnUser test
This commit is contained in:
+100
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"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-16T11:59:59.003453014Z",
|
||||
"banned": false,
|
||||
"online": true,
|
||||
"devices": [
|
||||
{
|
||||
"push_provider": "firebase",
|
||||
"id": "cRS8elU4Q-qqdCAvHR2kSa:APA91bFy7MEgPyXbnFWi3uoanr_x8Vbi42JcWOXlg8p3vyIL5FuW4bjpVfamqQjYCgwDGxPA0C4qavOadE-uiKeGQJp6Sp5D2KDW9Od_BlDqzwEPJnVG9gC1zbj7NKCfXRqbOA2Wh2mW",
|
||||
"created_at": "2020-04-23T14:36:21.838196Z",
|
||||
"user_id": "super-band-9"
|
||||
}
|
||||
],
|
||||
"mutes": [],
|
||||
"channel_mutes": [
|
||||
{
|
||||
"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-16T11:59:59.003453014Z",
|
||||
"banned": false,
|
||||
"online": true,
|
||||
"image": "https://placehold.jp/150x150.png",
|
||||
"invisible": false,
|
||||
"name": "Proud darkness",
|
||||
"unread_count": 0,
|
||||
"username": "Rioland"
|
||||
},
|
||||
"channel": {
|
||||
"id": "!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw",
|
||||
"type": "messaging",
|
||||
"cid": "messaging:!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw",
|
||||
"last_message_at": "2020-12-02T06:56:18.003432Z",
|
||||
"created_at": "2020-11-30T10:25:32.494601Z",
|
||||
"updated_at": "2020-11-30T10:25:32.494601Z",
|
||||
"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-16T11:59:59.003453014Z",
|
||||
"banned": false,
|
||||
"online": true,
|
||||
"unread_count": 0,
|
||||
"username": "Rioland",
|
||||
"image": "https://placehold.jp/150x150.png",
|
||||
"invisible": false,
|
||||
"name": "Proud darkness"
|
||||
},
|
||||
"frozen": false,
|
||||
"disabled": 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"created_at": "2020-12-04T10:39:06.512021Z",
|
||||
"updated_at": "2020-12-04T10:39:06.512021Z"
|
||||
}
|
||||
],
|
||||
"total_unread_count": 0,
|
||||
"unread_channels": 0,
|
||||
"language": "",
|
||||
"image": "https://placehold.jp/150x150.png",
|
||||
"name": "Proud darkness",
|
||||
"username": "Rioland"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:stream_chat/src/core/models/own_user.dart';
|
||||
import 'package:stream_chat/src/core/models/user.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../../utils.dart';
|
||||
|
||||
void main() {
|
||||
group('src/models/own_user', () {
|
||||
test('should parse json correctly', () {
|
||||
final ownUser = OwnUser.fromJson(jsonFixture('own_user.json'));
|
||||
expect(ownUser.id, 'super-band-9');
|
||||
expect(ownUser.role, 'user');
|
||||
|
||||
expect(ownUser.createdAt, DateTime.parse('2020-03-03T16:48:28.853674Z'));
|
||||
expect(ownUser.updatedAt, DateTime.parse('2021-05-26T03:22:20.296181Z'));
|
||||
expect(
|
||||
ownUser.lastActive, DateTime.parse('2021-06-16T11:59:59.003453014Z'));
|
||||
expect(ownUser.banned, false);
|
||||
expect(ownUser.online, true);
|
||||
expect(ownUser.devices.length, 1);
|
||||
expect(ownUser.mutes.length, 0);
|
||||
expect(ownUser.channelMutes.length, 1);
|
||||
expect(ownUser.totalUnreadCount, 0);
|
||||
expect(ownUser.unreadChannels, 0);
|
||||
expect(ownUser.extraData['image'], 'https://placehold.jp/150x150.png');
|
||||
expect(ownUser.extraData['name'], 'Proud darkness');
|
||||
expect(ownUser.extraData['username'], 'Rioland');
|
||||
});
|
||||
|
||||
test('should initialize a OwnUser from a User correctly', () {
|
||||
final user = User.fromJson(jsonFixture('user.json'));
|
||||
final ownUser = OwnUser.fromUser(user);
|
||||
|
||||
expect(ownUser.id, user.id);
|
||||
expect(ownUser.id, user.id);
|
||||
expect(ownUser.role, user.role);
|
||||
expect(ownUser.createdAt, user.createdAt);
|
||||
expect(ownUser.updatedAt, user.updatedAt);
|
||||
expect(ownUser.lastActive, user.lastActive);
|
||||
expect(ownUser.online, user.online);
|
||||
expect(ownUser.banned, user.banned);
|
||||
expect(ownUser.extraData, user.extraData);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user