Unit test search
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 1m42s
Cargo CI / Lint (pull_request) Successful in 1m15s

This commit is contained in:
Wojciech Kozlowski 2024-03-01 20:52:21 +01:00
parent da52299ba7
commit 90237fb77e

View File

@ -372,6 +372,50 @@ mod tests {
assert_eq!(search.inner.selection.artist.state.list.selected(), Some(3)); assert_eq!(search.inner.selection.artist.state.list.selected(), Some(3));
} }
#[test]
fn album_incremental_search() {
let mut search =
AppMachine::search(inner(music_hoard(COLLECTION.to_owned())), orig(Some(1)));
search.inner.selection.active = Category::Album;
let sel = &search.inner.selection;
assert_eq!(sel.artist.album.state.list.selected(), Some(0));
search.state.string = String::from("album_title ");
search.incremental_search(false);
let sel = &search.inner.selection;
assert_eq!(sel.artist.album.state.list.selected(), Some(0));
search.state.string = String::from("album_title a.b");
search.incremental_search(false);
let sel = &search.inner.selection;
assert_eq!(sel.artist.album.state.list.selected(), Some(1));
}
#[test]
fn track_incremental_search() {
let mut search =
AppMachine::search(inner(music_hoard(COLLECTION.to_owned())), orig(Some(1)));
search.inner.selection.active = Category::Track;
let sel = &search.inner.selection;
assert_eq!(sel.artist.album.track.state.list.selected(), Some(0));
search.state.string = String::from("track ");
search.incremental_search(false);
let sel = &search.inner.selection;
assert_eq!(sel.artist.album.track.state.list.selected(), Some(0));
search.state.string = String::from("track a.a.2");
search.incremental_search(false);
let sel = &search.inner.selection;
assert_eq!(sel.artist.album.track.state.list.selected(), Some(1));
}
#[test] #[test]
fn search() { fn search() {
let search = AppMachine::search(inner(music_hoard(COLLECTION.to_owned())), orig(Some(2))); let search = AppMachine::search(inner(music_hoard(COLLECTION.to_owned())), orig(Some(2)));