use super::*;
use crate::boundary::line::parse;
use crate::boundary::{Action, Gesture};
use crate::start::BallSpec;
#[test]
fn the_focus_is_what_a_line_elides() {
let w = world();
let (_c, mut m) = model(&w);
m.focus_workspace(&w.ws_cobalt);
let ctx = m.line_context();
assert_eq!(ctx.workspace.as_deref(), Some(w.ws_cobalt.as_path()));
assert_eq!(ctx.project.as_deref(), Some(w.project.as_path()));
assert_eq!(ctx.name.as_deref(), Some("cobalt"));
assert!(
matches!(ctx.ball, Some(BallSpec::Existing { ref id, .. }) if id == "bl-work"),
"the focused ball, whole: {:?}",
ctx.ball
);
assert_eq!(ctx.prepared, None);
assert_eq!(
parse("/close", &ctx),
Ok(Gesture::Act(Action::Close {
project: w.project.clone(),
id: "bl-work".to_owned(),
name: "cobalt".to_owned(),
}))
);
}
#[test]
fn a_workspace_with_no_ball_stamps_its_own_name() {
let w = world();
let (_c, mut m) = model(&w);
m.focus_workspace(&w.ws_spare);
let ctx = m.line_context();
assert_eq!(ctx.name.as_deref(), Some("spare"));
assert_eq!(ctx.project, None);
assert_eq!(ctx.ball, None);
assert!(parse("/close", &ctx).is_err(), "no project, no close");
}