Skip to content

Commit 977a999

Browse files
committed
timeline(tests): simplify matching a day divider or a read marker using public APIs
1 parent f978960 commit 977a999

File tree

1 file changed

+5
-5
lines changed
  • crates/matrix-sdk-ui/src/timeline/tests

1 file changed

+5
-5
lines changed

crates/matrix-sdk-ui/src/timeline/tests/virt.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use ruma::{
2525
use stream_assert::assert_next_matches;
2626

2727
use super::TestTimeline;
28-
use crate::timeline::{traits::RoomDataProvider as _, TimelineItemKind, VirtualTimelineItem};
28+
use crate::timeline::{traits::RoomDataProvider as _, VirtualTimelineItem};
2929

3030
#[async_test]
3131
async fn test_day_divider() {
@@ -84,7 +84,7 @@ async fn test_day_divider() {
8484
// The other events are in the past so a local event always creates a new day
8585
// divider.
8686
let day_divider = assert_next_matches!(stream, VectorDiff::Insert { index: 5, value } => value);
87-
assert_matches!(day_divider.as_virtual().unwrap(), VirtualTimelineItem::DayDivider { .. });
87+
assert!(day_divider.is_day_divider());
8888
}
8989

9090
#[async_test]
@@ -127,7 +127,7 @@ async fn test_update_read_marker() {
127127

128128
// Now the read marker is reinserted after the second event.
129129
let marker = assert_next_matches!(stream, VectorDiff::Insert { index: 3, value } => value);
130-
assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker));
130+
assert!(marker.is_read_marker());
131131

132132
// Nothing should happen if the fully read event is set back to an older event
133133
// sent by another user.
@@ -152,7 +152,7 @@ async fn test_update_read_marker() {
152152
// The read marker is moved after the third event (sent by another user).
153153
assert_next_matches!(stream, VectorDiff::Remove { index: 3 });
154154
let marker = assert_next_matches!(stream, VectorDiff::Insert { index: 4, value } => value);
155-
assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker));
155+
assert!(marker.is_read_marker());
156156

157157
// If the current user sends an event afterwards, the read marker doesn't move.
158158
timeline.handle_live_event(f.text_msg("E").sender(&own_user)).await;
@@ -186,5 +186,5 @@ async fn test_update_read_marker() {
186186
item.as_event().unwrap();
187187

188188
let marker = assert_next_matches!(stream, VectorDiff::Insert { index: 8, value } => value);
189-
assert_matches!(marker.kind, TimelineItemKind::Virtual(VirtualTimelineItem::ReadMarker));
189+
assert!(marker.is_read_marker());
190190
}

0 commit comments

Comments
 (0)