Update ignored_user_list tests
This commit is contained in:
parent
f23d7414ec
commit
d61b6c705c
@ -70,6 +70,7 @@ pub(crate) mod raw {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
|
use matches::assert_matches;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let json_data = json!({
|
let json = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"ignored_users": {
|
"ignored_users": {
|
||||||
"@carl:example.com": {}
|
"@carl:example.com": {}
|
||||||
@ -93,12 +94,12 @@ mod tests {
|
|||||||
"type": "m.ignored_user_list"
|
"type": "m.ignored_user_list"
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(to_json_value(ignored_user_list_event).unwrap(), json_data);
|
assert_eq!(to_json_value(ignored_user_list_event).unwrap(), json);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialization() {
|
fn deserialization() {
|
||||||
let json_data = json!({
|
let json = json!({
|
||||||
"content": {
|
"content": {
|
||||||
"ignored_users": {
|
"ignored_users": {
|
||||||
"@carl:example.com": {}
|
"@carl:example.com": {}
|
||||||
@ -107,17 +108,14 @@ mod tests {
|
|||||||
"type": "m.ignored_user_list"
|
"type": "m.ignored_user_list"
|
||||||
});
|
});
|
||||||
|
|
||||||
let actual = from_json_value::<EventJson<IgnoredUserListEvent>>(json_data)
|
assert_matches!(
|
||||||
|
from_json_value::<EventJson<IgnoredUserListEvent>>(json)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.deserialize()
|
.deserialize()
|
||||||
.unwrap();
|
.unwrap(),
|
||||||
|
IgnoredUserListEvent {
|
||||||
let expected = IgnoredUserListEvent {
|
content: IgnoredUserListEventContent { ignored_users, },
|
||||||
content: IgnoredUserListEventContent {
|
} if ignored_users == vec![UserId::try_from("@carl:example.com").unwrap()]
|
||||||
ignored_users: vec![UserId::try_from("@carl:example.com").unwrap()],
|
);
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(actual, expected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user