File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed
crates/matrix-sdk/src/sliding_sync Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -385,6 +385,65 @@ mod tests {
385
385
}
386
386
}
387
387
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
+
388
447
#[ test]
389
448
fn test_frozen_sliding_sync_room_serialization ( ) {
390
449
let frozen_sliding_sync_room = FrozenSlidingSyncRoom {
You can’t perform that action at this time.
0 commit comments