use super::*;
use crossterm::event::{KeyCode, KeyEvent};
fn app() -> App {
App::new(clap::Parser::parse_from(["met", "org/m"]))
}
fn press(a: &mut App, c: char) {
a.on_key(KeyEvent::from(KeyCode::Char(c)));
}
#[test]
fn q_asks_first_while_the_boot_load_is_still_running() {
let mut a = app(); assert_eq!(a.work_in_flight(), Some("a model is still loading"));
press(&mut a, 'q');
assert!(a.confirm_quit, "the first press asks");
assert!(!a.should_quit);
let mut a = app();
a.progress.ready = true;
press(&mut a, 'q');
assert!(a.should_quit);
assert!(!a.confirm_quit);
}
#[test]
fn an_awaiting_model_boot_quits_without_the_loading_prompt() {
let mut a = App::new(clap::Parser::parse_from(["met"]));
assert!(a.work_in_flight().is_none());
press(&mut a, 'q');
assert!(a.should_quit);
}