Add first test for display names

master
Valentin Brandl 2020-05-14 17:09:30 +02:00 committed by Denis Kasak
parent 05503b28b7
commit 9f34615869
1 changed files with 42 additions and 0 deletions

View File

@ -699,6 +699,48 @@ mod test {
assert!(room.deref().power_levels.is_some()) assert!(room.deref().power_levels.is_some())
} }
#[async_test]
async fn test_member_display_name() {
let client = get_client();
let client_2 = {
let session = Session {
access_token: "1234".to_owned(),
user_id: UserId::try_from("@example:hostlocal").unwrap(),
device_id: "DEVICEID".to_owned(),
};
BaseClient::new(Some(session)).unwrap()
};
let room_id = get_room_id();
let user_id = UserId::try_from("@example:localhost").unwrap();
let mut response = EventBuilder::default()
.add_room_event(EventsFile::Member, RoomEvent::RoomMember)
.build_sync_response();
client.receive_sync_response(&mut response).await.unwrap();
let room = client.get_joined_room(&room_id).await.unwrap();
let room = room.read().await;
let display_name = room.member_display_name(&user_id).unwrap();
assert_eq!("example", display_name);
let mut response = EventBuilder::default()
.add_room_event(EventsFile::Member, RoomEvent::RoomMember)
.build_sync_response();
client_2.receive_sync_response(&mut response).await.unwrap();
let room_2 = client_2.get_joined_room(&room_id).await.unwrap();
let room_2 = room_2.read().await;
let display_name_2 = room_2.member_display_name(&user_id).unwrap();
// TODO: this should change
assert_eq!("example", display_name_2);
}
#[async_test] #[async_test]
async fn room_events() { async fn room_events() {
let client = get_client().await; let client = get_client().await;