Skip to content

Commit e7e66dc

Browse files
committed
test(sdk): Test SlidingSyncRoom::required_state.
1 parent d688918 commit e7e66dc

File tree

1 file changed

+59
-0
lines changed
  • crates/matrix-sdk/src/sliding_sync

1 file changed

+59
-0
lines changed

crates/matrix-sdk/src/sliding_sync/room.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,65 @@ mod tests {
385385
}
386386
}
387387

388+
#[tokio::test]
389+
async fn test_required_state() -> Result<()> {
390+
// Default value.
391+
{
392+
let room = new_room(room_id!("!foo:bar.org"), room_response!({})).await;
393+
394+
assert!(room.required_state().is_empty());
395+
}
396+
397+
// Some value when initializing.
398+
{
399+
let room = new_room(
400+
room_id!("!foo:bar.org"),
401+
room_response!({
402+
"required_state": [
403+
{
404+
"sender": "@alice:example.com",
405+
"type": "m.room.join_rules",
406+
"state_key": "",
407+
"content": {
408+
"join_rule": "invite"
409+
}
410+
}
411+
]
412+
}),
413+
)
414+
.await;
415+
416+
assert!(!room.required_state().is_empty());
417+
}
418+
419+
// Some value when updating.
420+
{
421+
let mut room = new_room(room_id!("!foo:bar.org"), room_response!({})).await;
422+
423+
assert!(room.required_state().is_empty());
424+
425+
room.update(
426+
room_response!({
427+
"required_state": [
428+
{
429+
"sender": "@alice:example.com",
430+
"type": "m.room.join_rules",
431+
"state_key": "",
432+
"content": {
433+
"join_rule": "invite"
434+
}
435+
}
436+
]
437+
}),
438+
vec![],
439+
);
440+
441+
assert!(!room.required_state().is_empty());
442+
}
443+
444+
Ok(())
445+
}
446+
388447
#[test]
389448
fn test_frozen_sliding_sync_room_serialization() {
390449
let frozen_sliding_sync_room = FrozenSlidingSyncRoom {

0 commit comments

Comments
 (0)