use cydonia::view::component::transcript::{HEAD_MAX, title};
#[test]
fn a_script_is_one_line_and_a_way_back_to_the_rest() {
let script = "python3 -c \"\nimport json\nprint(json.dumps({}))\n\"";
let (name, rest, full) = title(script);
assert_eq!(name, "python3");
assert_eq!(
rest.expect("the command after the head"),
"-c \" import json print(json.dumps({})) \""
);
assert_eq!(full.expect("the script, as written"), script);
}
#[test]
fn a_short_title_opens_onto_nothing() {
let (name, rest, full) = title("Read src/view/root.rs");
assert_eq!(name, "Read");
assert_eq!(rest.expect("the path"), "src/view/root.rs");
assert!(full.is_none());
}
#[test]
fn a_head_longer_than_the_row_is_cut() {
let (name, rest, _) = title(&"x".repeat(40));
assert_eq!(name.len(), HEAD_MAX);
assert_eq!(rest.expect("what the head could not take").len(), 16);
}