use crate::test_support::window::{configured, seated};
use crate::ui::{Configuring, Model};
use crate::verbs::Where;
#[test]
fn the_pane_opens_only_where_the_window_is_aimed_at_a_wall() {
let mut nowhere = Model::default();
nowhere.begin_configuring();
assert_eq!(nowhere.configuring, None);
let mut model = seated();
model.begin_configuring();
assert_eq!(model.configuring, Some(Configuring::default()));
assert!(model.covered(), "it covers the conversation");
assert_eq!(model.configured(), None, "and points at nothing yet");
model.close_configuring();
assert_eq!(model.configuring, None);
}
#[test]
fn picking_a_file_points_the_pane_at_it_and_drops_the_last_bytes() {
let mut model = configured();
assert!(model.config.is_some());
model.read_config(&Where::Cadence);
assert_eq!(model.configured(), Some(Where::Cadence));
assert_eq!(model.config, None, "the last file's bytes go with it");
assert!(
model.outbox.is_empty(),
"the read stands rather than posting"
);
}
#[test]
fn a_pick_with_no_pane_open_points_at_nothing() {
let mut model = seated();
model.read_config(&Where::Cadence);
assert_eq!(model.configured(), None);
}
#[test]
fn escape_puts_it_down_and_a_new_aim_retires_it() {
let mut model = configured();
model.escape();
assert_eq!(model.configuring, None);
assert!(model.config.is_some(), "the answers are the engine's");
let mut moved = configured();
moved.aim_at("(this box's own engine)", "elsewhere");
assert_eq!(moved.configuring, None);
assert_eq!(moved.config, None);
assert_eq!(moved.lineages, None);
}