Test new UI methods
This commit is contained in:
parent
bbf37c8715
commit
8c8e6971c5
@ -102,6 +102,8 @@ mod tests {
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers};
|
||||
|
||||
use crate::tui::ui::UiError;
|
||||
|
||||
use super::{Event, EventChannel, EventError};
|
||||
|
||||
#[test]
|
||||
@ -145,13 +147,16 @@ mod tests {
|
||||
}));
|
||||
let recv_err = EventError::Recv;
|
||||
let io_err = EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "interrupted"));
|
||||
let ui_err: EventError = UiError::Lib(String::from("lib error")).into();
|
||||
|
||||
assert!(!send_err.to_string().is_empty());
|
||||
assert!(!recv_err.to_string().is_empty());
|
||||
assert!(!io_err.to_string().is_empty());
|
||||
assert!(!ui_err.to_string().is_empty());
|
||||
|
||||
assert!(!format!("{:?}", send_err).is_empty());
|
||||
assert!(!format!("{:?}", recv_err).is_empty());
|
||||
assert!(!format!("{:?}", io_err).is_empty());
|
||||
assert!(!format!("{:?}", ui_err).is_empty());
|
||||
}
|
||||
}
|
||||
|
@ -809,6 +809,21 @@ mod tests {
|
||||
assert!(!ui.is_running());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui_save() {
|
||||
let mut music_hoard = music_hoard(COLLECTION.to_owned());
|
||||
|
||||
music_hoard
|
||||
.expect_save_to_database()
|
||||
.times(1)
|
||||
.return_once(|| Ok(()));
|
||||
|
||||
let mut ui = Ui::new(music_hoard).unwrap();
|
||||
|
||||
let result = ui.save();
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui_modifiers() {
|
||||
let mut ui = Ui::new(music_hoard(COLLECTION.to_owned())).unwrap();
|
||||
@ -1044,4 +1059,13 @@ mod tests {
|
||||
|
||||
terminal.draw(|frame| ui.render(frame)).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors() {
|
||||
let ui_err: UiError = musichoard::Error::DatabaseError(String::from("get rekt")).into();
|
||||
|
||||
assert!(!ui_err.to_string().is_empty());
|
||||
|
||||
assert!(!format!("{:?}", ui_err).is_empty());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user