test(ui): Add more tests.

This commit is contained in:
Ivan Enderlin
2023-09-15 13:46:41 +02:00
parent d12eda5839
commit be6da14f16
3 changed files with 34 additions and 6 deletions

View File

@@ -110,10 +110,10 @@ impl RoomList {
/// possible to “paginate” over the entries by `page_size`.
///
/// The returned stream will only start yielding diffs once a filter is set
/// through the returned `DynamicRoomListController`. For every call to
/// [`DynamicRoomListController::set`], the stream will yield a
/// [`VectorDiff::Reset`] followed by any updates of the room list under
/// that filter (until the next reset).
/// through the returned [`RoomListDynamicEntriesController`]. For every
/// call to [`RoomListDynamicEntriesController::set_filter`], the stream
/// will yield a [`VectorDiff::Truncate`] followed by any updates of the
/// room list under that filter (until the next reset).
pub fn entries_with_dynamic_adapters(
&self,
page_size: usize,
@@ -240,7 +240,8 @@ impl RoomListDynamicEntriesController {
}
}
/// Add one page.
/// Add one page, i.e. view `page_size` more entries in the room list if
/// any.
pub fn add_one_page(&self) {
if let Some(max) = self.maximum_number_of_rooms.borrow_mut().next_now() {
let max: usize = max.try_into().unwrap();

View File

@@ -1809,6 +1809,34 @@ async fn test_dynamic_entries_stream() -> Result<(), Error> {
};
assert_pending!(dynamic_entries_stream);
// Let's reset to one page.
dynamic_entries.reset_to_one_page();
// Assert the dynamic entries.
assert_entries_batch! {
[dynamic_entries_stream]
// Receive a `truncate`.
truncate [5];
end;
}
assert_pending!(dynamic_entries_stream);
// Let's ask one more page again, because it's fun.
dynamic_entries.add_one_page();
// Assert the dynamic entries.
assert_entries_batch! {
[dynamic_entries_stream]
// Receive the next values.
append [
F("!r5:bar.org"),
F("!r6:bar.org"),
F("!r7:bar.org"),
];
end;
};
assert_pending!(dynamic_entries_stream);
Ok(())
}

View File

@@ -279,7 +279,6 @@ mod tests {
use std::sync::{Arc, RwLock};
use assert_matches::assert_matches;
use futures_util::StreamExt;
use matrix_sdk_test::async_test;
use super::{