Move tests
This commit is contained in:
parent
127da2b180
commit
d427612bbf
@ -840,4 +840,92 @@ mod tests {
|
|||||||
sel.reinitialise(&[], active_artist);
|
sel.reinitialise(&[], active_artist);
|
||||||
assert_eq!(sel, expected);
|
assert_eq!(sel, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn selection() {
|
||||||
|
let mut selection = Selection::new(&COLLECTION);
|
||||||
|
|
||||||
|
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(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_selection(&COLLECTION, Delta::Line);
|
||||||
|
assert_eq!(selection.active, Category::Artist);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_category();
|
||||||
|
assert_eq!(selection.active, Category::Album);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_selection(&COLLECTION, Delta::Line);
|
||||||
|
assert_eq!(selection.active, Category::Album);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_category();
|
||||||
|
assert_eq!(selection.active, Category::Track);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_selection(&COLLECTION, Delta::Line);
|
||||||
|
assert_eq!(selection.active, Category::Track);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(1));
|
||||||
|
|
||||||
|
selection.increment_category();
|
||||||
|
assert_eq!(selection.active, Category::Track);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(1));
|
||||||
|
|
||||||
|
selection.decrement_selection(&COLLECTION, Delta::Line);
|
||||||
|
assert_eq!(selection.active, Category::Track);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_selection(&COLLECTION, Delta::Line);
|
||||||
|
selection.decrement_category();
|
||||||
|
assert_eq!(selection.active, Category::Album);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(1));
|
||||||
|
|
||||||
|
selection.decrement_selection(&COLLECTION, Delta::Line);
|
||||||
|
assert_eq!(selection.active, Category::Album);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_selection(&COLLECTION, Delta::Line);
|
||||||
|
selection.decrement_category();
|
||||||
|
assert_eq!(selection.active, Category::Artist);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
|
||||||
|
selection.decrement_selection(&COLLECTION, Delta::Line);
|
||||||
|
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(), Some(0));
|
||||||
|
|
||||||
|
selection.increment_category();
|
||||||
|
selection.increment_selection(&COLLECTION, Delta::Line);
|
||||||
|
selection.decrement_category();
|
||||||
|
selection.decrement_selection(&COLLECTION, Delta::Line);
|
||||||
|
selection.decrement_category();
|
||||||
|
assert_eq!(selection.active, Category::Artist);
|
||||||
|
assert_eq!(selection.artist.state.list.selected(), Some(0));
|
||||||
|
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
||||||
|
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,11 +66,7 @@ mod tests {
|
|||||||
use musichoard::collection::Collection;
|
use musichoard::collection::Collection;
|
||||||
|
|
||||||
use crate::tui::{
|
use crate::tui::{
|
||||||
app::{
|
app::{app::App, AppState, IAppInteract},
|
||||||
app::App,
|
|
||||||
selection::{Category, Delta},
|
|
||||||
AppState, IAppInteract, IAppInteractBrowse,
|
|
||||||
},
|
|
||||||
lib::MockIMusicHoard,
|
lib::MockIMusicHoard,
|
||||||
testmod::COLLECTION,
|
testmod::COLLECTION,
|
||||||
};
|
};
|
||||||
@ -183,108 +179,4 @@ mod tests {
|
|||||||
assert!(app.is_running());
|
assert!(app.is_running());
|
||||||
app.unwrap_critical();
|
app.unwrap_critical();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn modifiers() {
|
|
||||||
let app = App::new(music_hoard_app(COLLECTION.to_owned()));
|
|
||||||
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(), Some(0));
|
|
||||||
|
|
||||||
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(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
let browse = browse.increment_category().unwrap_browse();
|
|
||||||
let selection = &browse.inner.selection;
|
|
||||||
assert_eq!(selection.active, Category::Album);
|
|
||||||
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
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(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
let browse = browse.increment_category().unwrap_browse();
|
|
||||||
let selection = &browse.inner.selection;
|
|
||||||
assert_eq!(selection.active, Category::Track);
|
|
||||||
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
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(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(1));
|
|
||||||
|
|
||||||
let browse = browse.increment_category().unwrap_browse();
|
|
||||||
let selection = &browse.inner.selection;
|
|
||||||
assert_eq!(selection.active, Category::Track);
|
|
||||||
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(1));
|
|
||||||
|
|
||||||
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(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
|
||||||
let browse = browse.decrement_category().unwrap_browse();
|
|
||||||
let selection = &browse.inner.selection;
|
|
||||||
assert_eq!(selection.active, Category::Album);
|
|
||||||
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(1));
|
|
||||||
|
|
||||||
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(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
|
||||||
let browse = browse.decrement_category().unwrap_browse();
|
|
||||||
let selection = &browse.inner.selection;
|
|
||||||
assert_eq!(selection.active, Category::Artist);
|
|
||||||
assert_eq!(selection.artist.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
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(), Some(0));
|
|
||||||
assert_eq!(selection.artist.album.state.list.selected(), Some(0));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
|
|
||||||
let browse = browse.increment_category().unwrap_browse();
|
|
||||||
let browse = browse.increment_selection(Delta::Line).unwrap_browse();
|
|
||||||
let browse = browse.decrement_category().unwrap_browse();
|
|
||||||
let browse = browse.decrement_selection(Delta::Line).unwrap_browse();
|
|
||||||
let browse = browse.decrement_category().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(1));
|
|
||||||
assert_eq!(selection.artist.album.track.state.list.selected(), Some(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user