chore: Add tests for converting event types
This commit is contained in:
parent
83f993a2ff
commit
1484e6770f
|
|
@ -241,6 +241,9 @@ class Event extends MatrixEvent {
|
||||||
if (originalSource != null) {
|
if (originalSource != null) {
|
||||||
data['original_source'] = originalSource?.toJson();
|
data['original_source'] = originalSource?.toJson();
|
||||||
}
|
}
|
||||||
|
if (redacts != null) {
|
||||||
|
data['redacts'] = redacts;
|
||||||
|
}
|
||||||
data['status'] = status.intValue;
|
data['status'] = status.intValue;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,6 @@ void main() {
|
||||||
expect(event.redacted, true);
|
expect(event.redacted, true);
|
||||||
expect(event.redactedBecause?.toJson(), redactedBecause.toJson());
|
expect(event.redactedBecause?.toJson(), redactedBecause.toJson());
|
||||||
expect(event.content.isEmpty, true);
|
expect(event.content.isEmpty, true);
|
||||||
redactionEventJson.remove('redacts');
|
|
||||||
expect(event.unsigned?['redacted_because'], redactionEventJson);
|
expect(event.unsigned?['redacted_because'], redactionEventJson);
|
||||||
|
|
||||||
await client.dispose();
|
await client.dispose();
|
||||||
|
|
@ -2830,5 +2829,38 @@ void main() {
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 2);
|
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