@@ -269,7 +269,7 @@ impl From<&SlidingSyncRoom> for FrozenSlidingSyncRoom {
269
269
mod tests {
270
270
use imbl:: vector;
271
271
use matrix_sdk_base:: deserialized_responses:: TimelineEvent ;
272
- use ruma:: { events:: room:: message:: RoomMessageEventContent , room_id, RoomId } ;
272
+ use ruma:: { events:: room:: message:: RoomMessageEventContent , room_id, uint , RoomId } ;
273
273
use serde_json:: json;
274
274
use wiremock:: MockServer ;
275
275
@@ -305,10 +305,9 @@ mod tests {
305
305
(
306
306
$(
307
307
$test_name: ident {
308
- $getter: ident ( ) =
309
- $first_value: expr;
310
- $room_response: expr;
311
- $second_value: expr;
308
+ $getter: ident ( ) $( . $getter_field: ident ) ? = $first_value: expr;
309
+ receives $room_response: expr;
310
+ _ = $second_value: expr;
312
311
}
313
312
) +
314
313
) => {
@@ -319,26 +318,26 @@ mod tests {
319
318
{
320
319
let room = new_room( room_id!( "!foo:bar.org" ) , room_response!( { } ) ) . await ;
321
320
322
- assert_eq!( room. $getter( ) , None ) ;
321
+ assert_eq!( room. $getter( ) $ ( . $getter_field ) ? , $first_value ) ;
323
322
}
324
323
325
324
// Some value when initializing.
326
325
{
327
326
let room = new_room( room_id!( "!foo:bar.org" ) , $room_response) . await ;
328
327
329
- assert_eq!( room. $getter( ) , $second_value) ;
328
+ assert_eq!( room. $getter( ) $ ( . $getter_field ) ? , $second_value) ;
330
329
}
331
330
332
331
// Some value when updating.
333
332
{
334
333
335
334
let mut room = new_room( room_id!( "!foo:bar.org" ) , room_response!( { } ) ) . await ;
336
335
337
- assert_eq!( room. $getter( ) , $first_value) ;
336
+ assert_eq!( room. $getter( ) $ ( . $getter_field ) ? , $first_value) ;
338
337
339
338
room. update( $room_response, vec![ ] ) ;
340
339
341
- assert_eq!( room. $getter( ) , $second_value) ;
340
+ assert_eq!( room. $getter( ) $ ( . $getter_field ) ? , $second_value) ;
342
341
}
343
342
344
343
Ok ( ( ) )
@@ -349,15 +348,45 @@ mod tests {
349
348
350
349
test_getters ! {
351
350
test_room_name {
352
- name( ) = None ; room_response!( { "name" : "gordon" } ) ; Some ( "gordon" ) ;
351
+ name( ) = None ;
352
+ receives room_response!( { "name" : "gordon" } ) ;
353
+ _ = Some ( "gordon" ) ;
353
354
}
354
355
355
356
test_room_is_dm {
356
- is_dm( ) = None ; room_response!( { "is_dm" : true } ) ; Some ( true ) ;
357
+ is_dm( ) = None ;
358
+ receives room_response!( { "is_dm" : true } ) ;
359
+ _ = Some ( true ) ;
357
360
}
358
361
359
362
test_room_is_initial_response {
360
- is_initial_response( ) = None ; room_response!( { "initial" : true } ) ; Some ( true ) ;
363
+ is_initial_response( ) = None ;
364
+ receives room_response!( { "initial" : true } ) ;
365
+ _ = Some ( true ) ;
366
+ }
367
+
368
+ test_has_unread_notifications_with_notification_count {
369
+ has_unread_notifications( ) = false ;
370
+ receives room_response!( { "notification_count" : 42 } ) ;
371
+ _ = true ;
372
+ }
373
+
374
+ test_has_unread_notifications_with_highlight_count {
375
+ has_unread_notifications( ) = false ;
376
+ receives room_response!( { "highlight_count" : 42 } ) ;
377
+ _ = true ;
378
+ }
379
+
380
+ test_unread_notifications_with_notification_count {
381
+ unread_notifications( ) . notification_count = None ;
382
+ receives room_response!( { "notification_count" : 42 } ) ;
383
+ _ = Some ( uint!( 42 ) ) ;
384
+ }
385
+
386
+ test_unread_notifications_with_highlight_count {
387
+ unread_notifications( ) . highlight_count = None ;
388
+ receives room_response!( { "highlight_count" : 42 } ) ;
389
+ _ = Some ( uint!( 42 ) ) ;
361
390
}
362
391
}
363
392
0 commit comments