add event tests
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user