Provide search functionality through the TUI #134
@ -495,7 +495,13 @@ mod tests {
|
||||
let tracks = &COLLECTION[0].albums[0].tracks;
|
||||
assert!(tracks.len() > 1);
|
||||
|
||||
let empty = TrackSelection::initialise(&[]);
|
||||
let mut empty = TrackSelection::initialise(&[]);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
|
||||
empty.increment(tracks, Delta::Line);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
|
||||
empty.decrement(tracks, Delta::Line);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
|
||||
let mut sel = TrackSelection::initialise(tracks);
|
||||
@ -578,8 +584,17 @@ mod tests {
|
||||
let albums = &COLLECTION[0].albums;
|
||||
assert!(albums.len() > 1);
|
||||
|
||||
let empty = AlbumSelection::initialise(&[]);
|
||||
let mut empty = AlbumSelection::initialise(&[]);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
assert_eq!(empty.track.state.list.selected(), None);
|
||||
|
||||
empty.increment(albums, Delta::Line);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
assert_eq!(empty.track.state.list.selected(), None);
|
||||
|
||||
empty.decrement(albums, Delta::Line);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
assert_eq!(empty.track.state.list.selected(), None);
|
||||
|
||||
let mut sel = AlbumSelection::initialise(albums);
|
||||
assert_eq!(sel.state.list.selected(), Some(0));
|
||||
@ -700,8 +715,17 @@ mod tests {
|
||||
let artists = &COLLECTION;
|
||||
assert!(artists.len() > 1);
|
||||
|
||||
let empty = ArtistSelection::initialise(&[]);
|
||||
let mut empty = ArtistSelection::initialise(&[]);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
assert_eq!(empty.album.state.list.selected(), None);
|
||||
|
||||
empty.increment(artists, Delta::Line);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
assert_eq!(empty.album.state.list.selected(), None);
|
||||
|
||||
empty.decrement(artists, Delta::Line);
|
||||
assert_eq!(empty.state.list.selected(), None);
|
||||
assert_eq!(empty.album.state.list.selected(), None);
|
||||
|
||||
let mut sel = ArtistSelection::initialise(artists);
|
||||
assert_eq!(sel.state.list.selected(), Some(0));
|
||||
|
@ -287,147 +287,4 @@ mod tests {
|
||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_tracks() {
|
||||
let mut collection = COLLECTION.to_owned();
|
||||
collection[0].albums[0].tracks = vec![];
|
||||
|
||||
let app = App::new(music_hoard_app(collection));
|
||||
assert!(app.is_running());
|
||||
|
||||
let browse = app.unwrap_browse();
|
||||
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Artist);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.increment_category().unwrap_browse();
|
||||
let browse = browse.increment_category().unwrap_browse();
|
||||
|
||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Track);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Track);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_albums() {
|
||||
let mut collection = COLLECTION.to_owned();
|
||||
collection[0].albums = vec![];
|
||||
|
||||
let app = App::new(music_hoard_app(collection));
|
||||
assert!(app.is_running());
|
||||
|
||||
let browse = app.unwrap_browse();
|
||||
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Artist);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.increment_category().unwrap_browse();
|
||||
|
||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Album);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Album);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.increment_category().unwrap_browse();
|
||||
|
||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Track);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Track);
|
||||
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_artists() {
|
||||
let app = App::new(music_hoard_app(vec![]));
|
||||
assert!(app.is_running());
|
||||
|
||||
let browse = app.unwrap_browse();
|
||||
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Artist);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Artist);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Artist);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.increment_category().unwrap_browse();
|
||||
|
||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Album);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Album);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.increment_category().unwrap_browse();
|
||||
|
||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Track);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
|
||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
||||
let selection = &browse.inner.selection;
|
||||
assert_eq!(selection.active, Category::Track);
|
||||
assert_eq!(selection.artist.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.state.list.selected(), None);
|
||||
assert_eq!(selection.artist.album.track.state.list.selected(), None);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user