Merge pull request #2002 from famedly/krille/tests-for-event-convert
chore: Add tests for converting event types
This commit is contained in:
commit
cc9e046aa2
|
|
@ -241,6 +241,9 @@ class Event extends MatrixEvent {
|
|||
if (originalSource != null) {
|
||||
data['original_source'] = originalSource?.toJson();
|
||||
}
|
||||
if (redacts != null) {
|
||||
data['redacts'] = redacts;
|
||||
}
|
||||
data['status'] = status.intValue;
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,6 @@ void main() {
|
|||
expect(event.redacted, true);
|
||||
expect(event.redactedBecause?.toJson(), redactedBecause.toJson());
|
||||
expect(event.content.isEmpty, true);
|
||||
redactionEventJson.remove('redacts');
|
||||
expect(event.unsigned?['redacted_because'], redactionEventJson);
|
||||
|
||||
await client.dispose();
|
||||
|
|
@ -2830,5 +2829,38 @@ void main() {
|
|||
expect(event.onlyEmotes, false);
|
||||
expect(event.numberEmotes, 2);
|
||||
});
|
||||
|
||||
test('Check conversion between types', () {
|
||||
final matrixEvent = MatrixEvent.fromJson(
|
||||
{
|
||||
'content': {
|
||||
'body': 'filename.jpg',
|
||||
'info': {
|
||||
'h': 398,
|
||||
'mimetype': 'image/jpeg',
|
||||
'size': 31037,
|
||||
'w': 394,
|
||||
},
|
||||
'msgtype': 'm.image',
|
||||
'url': 'mxc://example.org/JWEIFJgwEIhweiWJE',
|
||||
},
|
||||
'event_id': '\$143273582443PhrSn:example.org',
|
||||
'origin_server_ts': 1432735824653,
|
||||
'room_id': room.id,
|
||||
'sender': '@example:example.org',
|
||||
'type': 'm.room.message',
|
||||
'unsigned': {'age': 1234},
|
||||
'redacts': 'abcd',
|
||||
'prev_content': <String, Object?>{
|
||||
'foo': 'bar',
|
||||
},
|
||||
},
|
||||
);
|
||||
final event = Event.fromMatrixEvent(matrixEvent, room);
|
||||
expect(
|
||||
event.toJson()..remove('status'),
|
||||
matrixEvent.toJson(),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue