use super::{attempt, changed, churn, ending, receipt};
use crate::reply::diff::Churn;
use crate::test_support::window::diff;
use crate::ui::model::Armed;
#[test]
fn the_receipt_names_the_op_it_answers_and_never_a_family() {
assert_eq!(
receipt(&Armed {
op: "fleet".to_owned(),
armed: true
}),
"fleet: it is standing"
);
assert_eq!(
receipt(&Armed {
op: "disarm".to_owned(),
armed: false
}),
"disarm: it is not standing"
);
}
#[test]
fn an_attempt_says_what_it_has_and_stays_silent_about_the_rest() {
let bare = attempt(&crate::test_support::window::attempt("bl-9", "pending"));
assert_eq!(bare.len(), 3, "{bare:?}");
assert!(bare[0].contains("bl-9"), "{bare:?}");
assert!(bare[0].contains("pending"), "{bare:?}");
assert!(bare[1].contains("4 steps"), "{bare:?}");
let whole = crate::reply::science::Attempt {
goal: Some("ship it".to_owned()),
conversation: Some("c-1".to_owned()),
base: Some("f00d".to_owned()),
governing: Some("dead".to_owned()),
response: Some("done".to_owned()),
pins: vec!["AGENTS.md".to_owned()],
verdicts: vec![crate::reply::science::Verdict {
sender: "judge".to_owned(),
body: "cleaner".to_owned(),
}],
compacted: Some(12),
..crate::test_support::window::attempt("bl-1", "accepted")
};
let said = attempt(&whole).join("\n");
for line in [
"ship it",
"in c-1",
"from f00d",
"governed by dead",
"said done",
"pinned AGENTS.md",
"judge — cleaner",
"12 entries compacted",
] {
assert!(said.contains(line), "{line:?} is on no line: {said}");
}
}
#[test]
fn the_ending_says_the_token_and_the_two_facts_beside_it() {
let mut row = crate::test_support::window::attempt("bl-1", "accepted");
assert_eq!(ending(&row), "accepted");
row.outcome.commit = Some("ccc".to_owned());
row.outcome.by = Some("at-1".to_owned());
assert_eq!(ending(&row), "accepted at ccc by at-1");
}
#[test]
fn a_diff_row_says_the_state_s_own_facts() {
assert_eq!(changed(&diff("bl-1", "unreadable")), "bl-1 [unreadable]");
let gone = crate::reply::diff::Diff {
source: Some("work/bl-2".to_owned()),
target: Some("main".to_owned()),
missing: vec!["work/bl-2".to_owned()],
..diff("bl-2", "absent")
};
assert_eq!(
changed(&gone),
"bl-2 [absent] work/bl-2 → main no such ref: work/bl-2"
);
let moved = crate::reply::diff::Diff {
source: Some("attempt/at-1".to_owned()),
target: Some("work/bl-3".to_owned()),
handle: Some("at-1".to_owned()),
delivered: Some("ccc".to_owned()),
truncated: Some(true),
..diff("bl-3", "diff")
};
assert_eq!(
changed(&moved),
"bl-3 [diff] attempt/at-1 → work/bl-3 candidate at-1 delivered ccc \
(the listing was cut)"
);
}
#[test]
fn a_churn_says_its_counts_or_says_binary() {
assert_eq!(
churn(&Churn {
path: "src/a.rs".to_owned(),
added: Some(3),
removed: Some(1),
binary: None
}),
"src/a.rs +3 −1"
);
assert_eq!(
churn(&Churn {
path: "assets/x.png".to_owned(),
added: None,
removed: None,
binary: Some(true)
}),
"assets/x.png binary"
);
}