events: Make more test assertions more helpful
This commit is contained in:
parent
b66b4a78e8
commit
e0de3d164b
@ -85,8 +85,8 @@ mod tests {
|
||||
from_json_value(json_data).unwrap();
|
||||
|
||||
assert!(server_acl_event.content.allow_ip_literals);
|
||||
assert!(server_acl_event.content.allow.is_empty());
|
||||
assert!(server_acl_event.content.deny.is_empty());
|
||||
assert_eq!(server_acl_event.content.allow.len(), 0);
|
||||
assert_eq!(server_acl_event.content.deny.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -43,6 +43,7 @@ fn deserialize_ephemeral_typing() {
|
||||
from_json_value::<AnyEphemeralRoomEvent>(json_data),
|
||||
Ok(AnyEphemeralRoomEvent::Typing(typing_event)) => typing_event
|
||||
);
|
||||
assert_eq!(typing_event.content.user_ids.len(), 1);
|
||||
assert_eq!(typing_event.content.user_ids[0], "@carl:example.com");
|
||||
assert_eq!(typing_event.room_id, "!roomid:room.com");
|
||||
}
|
||||
@ -101,11 +102,10 @@ fn deserialize_ephemeral_receipt() {
|
||||
Ok(AnyEphemeralRoomEvent::Receipt(receipt_event)) => receipt_event
|
||||
);
|
||||
let receipts = receipt_event.content.0;
|
||||
assert!(!receipts.is_empty());
|
||||
assert!(receipts.contains_key(event_id));
|
||||
assert_eq!(receipts.len(), 1);
|
||||
assert_eq!(receipt_event.room_id, "!roomid:room.com");
|
||||
let event_receipts = assert_matches!(receipts.get(event_id), Some(r) => r);
|
||||
let type_receipts = assert_matches!(event_receipts.get(&ReceiptType::Read), Some(r) => r);
|
||||
let user_receipt = assert_matches!(type_receipts.get(user_id), Some(r) => r);
|
||||
let event_receipts = receipts.get(event_id).unwrap();
|
||||
let type_receipts = event_receipts.get(&ReceiptType::Read).unwrap();
|
||||
let user_receipt = type_receipts.get(user_id).unwrap();
|
||||
assert_eq!(user_receipt.ts, Some(MilliSecondsSinceUnixEpoch(uint!(1))));
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ fn plain_content_deserialization() {
|
||||
assert_matches!(content.file.encryption_info, None);
|
||||
assert_eq!(content.image.width, Some(uint!(668)));
|
||||
assert_eq!(content.image.height, None);
|
||||
assert!(content.thumbnail.is_empty());
|
||||
assert_eq!(content.thumbnail.len(), 0);
|
||||
let caption = content.caption.unwrap();
|
||||
assert_eq!(caption.find_plain(), Some("Look at my cat!"));
|
||||
}
|
||||
@ -300,7 +300,7 @@ fn message_event_deserialization() {
|
||||
assert_eq!(info.size, Some(uint!(123_774)));
|
||||
assert_eq!(content.image.width, Some(uint!(1300)));
|
||||
assert_eq!(content.image.height, Some(uint!(837)));
|
||||
assert!(content.thumbnail.is_empty());
|
||||
assert_eq!(content.thumbnail.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -222,7 +222,7 @@ fn plain_content_deserialization() {
|
||||
assert_eq!(content.video.width, None);
|
||||
assert_eq!(content.video.height, None);
|
||||
assert_eq!(content.video.duration, Some(Duration::from_millis(5_668)));
|
||||
assert!(content.thumbnail.is_empty());
|
||||
assert_eq!(content.thumbnail.len(), 0);
|
||||
let caption = content.caption.unwrap();
|
||||
assert_eq!(caption.find_plain(), Some("Look at my cat!"));
|
||||
assert_eq!(caption.find_html(), None);
|
||||
@ -308,7 +308,7 @@ fn message_event_deserialization() {
|
||||
assert_eq!(content.video.width, Some(uint!(1300)));
|
||||
assert_eq!(content.video.height, Some(uint!(837)));
|
||||
assert_eq!(content.video.duration, None);
|
||||
assert!(content.thumbnail.is_empty());
|
||||
assert_eq!(content.thumbnail.len(), 0);
|
||||
|
||||
let info = content.file.info.unwrap();
|
||||
assert_eq!(info.name.as_deref(), Some("my_gnome.webm"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user