use super::*;
#[test]
fn show_folds_the_read_dispatch_lines_into_the_field_block_not_json() {
let s = git_store();
s.create("bl-1", &rich_task(), 100);
let cat = Catalog::load(s.dir()).unwrap();
let out = dispatch(s.dir(), &cat, &flags(false, "bl-1"), &plain(), " worktree /wt/bl-1\n", NOW).unwrap();
assert!(out.contains(" worktree /wt/bl-1\n\nSome body text."), "fold precedes the body:\n{out}");
let json = dispatch(s.dir(), &cat, &flags(true, "bl-1"), &plain(), " worktree /wt/bl-1\n", NOW).unwrap();
assert!(!json.contains("worktree"));
}
#[test]
fn show_hangs_a_comment_byline_under_each_comment_and_json_carries_none() {
let s = git_store();
let mut t = task("A ball", 100);
t.body = "The original body, as filed.\n".into();
let commented = "The original body, as filed.\n\n---\n\nsingle-clone runs pass\n";
s.create("bl-1", &t, 100);
s.edit("bl-1", &t, "comment", commented, 200);
let cat = Catalog::load(s.dir()).unwrap();
let out = dispatch(s.dir(), &cat, &flags(false, "bl-1"), &plain(), "", NOW).unwrap();
assert!(
out.contains("\nThe original body, as filed.\n\n---\n\nsingle-clone runs pass\n 1970-01-01T00:03:20Z t\n"),
"byline under the comment, original bare:\n{out}"
);
let json = dispatch(s.dir(), &cat, &flags(true, "bl-1"), &plain(), "", NOW).unwrap();
let v: serde_json::Value = serde_json::from_str(&json).unwrap();
assert_eq!(v["body"], commented, "the body verbatim, unannotated");
assert!(!json.contains("1970-01-01"), "no derived date anywhere in bedrock:\n{json}");
}
#[test]
fn show_renders_a_legacy_ball_bare_and_walks_this_store_for_nothing() {
let cat = catalog(&[("bl-1", rich_task())]);
let legacy = Flags { legacy: Some("balls/tasks:.balls/tasks".into()), ..flags(false, "bl-1") };
let out = dispatch(nostore(), &cat, &legacy, &plain(), "", NOW).unwrap();
assert!(out.ends_with("Some body text."), "the stored body, bare:\n{out}");
assert!(!out.contains("journal") && !out.contains("ago)"), "no store-derived line:\n{out}");
}