From 977a9995fe59559361a99b7a923dd67da86cdf6c Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 4 Sep 2024 17:38:33 +0200 Subject: [PATCH] timeline(tests): simplify matching a day divider or a read marker using public APIs --- crates/matrix-sdk-ui/src/timeline/tests/virt.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/matrix-sdk-ui/src/timeline/tests/virt.rs b/crates/matrix-sdk-ui/src/timeline/tests/virt.rs index 1e788a841..42e299ad7 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/virt.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/virt.rs @@ -25,7 +25,7 @@ use ruma::{ use stream_assert::assert_next_matches; use super::TestTimeline; -use crate::timeline::{traits::RoomDataProvider as _, TimelineItemKind, VirtualTimelineItem}; +use crate::timeline::{traits::RoomDataProvider as _, VirtualTimelineItem}; #[async_test] async fn test_day_divider() { @@ -84,7 +84,7 @@ async fn test_day_divider() { // The other events are in the past so a local event always creates a new day // divider. let day_divider = assert_next_matches!(stream, VectorDiff::Insert { index: 5, value } => value); - assert_matches!(day_divider.as_virtual().unwrap(), VirtualTimelineItem::DayDivider { .. }); + assert!(day_divider.is_day_divider()); } #[async_test] @@ -127,7 +127,7 @@ async fn test_update_read_marker() { // Now the read marker is reinserted after the second event. let marker = assert_next_matches!(stream, VectorDiff::Insert { index: 3, value } => value); - assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker)); + assert!(marker.is_read_marker()); // Nothing should happen if the fully read event is set back to an older event // sent by another user. @@ -152,7 +152,7 @@ async fn test_update_read_marker() { // The read marker is moved after the third event (sent by another user). assert_next_matches!(stream, VectorDiff::Remove { index: 3 }); let marker = assert_next_matches!(stream, VectorDiff::Insert { index: 4, value } => value); - assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker)); + assert!(marker.is_read_marker()); // If the current user sends an event afterwards, the read marker doesn't move. timeline.handle_live_event(f.text_msg("E").sender(&own_user)).await; @@ -186,5 +186,5 @@ async fn test_update_read_marker() { item.as_event().unwrap(); let marker = assert_next_matches!(stream, VectorDiff::Insert { index: 8, value } => value); - assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker)); + assert!(marker.is_read_marker()); }