use super::super::help;
use crate::reply::convs::{AgentState, ConvRow};
use crate::test_support::window::conv;
const CLICK: &str = " — click shows this conversation";
#[test]
fn the_sentence_leads_with_the_state_in_words() {
for (state, said) in [
(AgentState::Live, "working"),
(AgentState::InFlight, "working"),
(AgentState::Quiescent, "at rest"),
(AgentState::Stopped, "stopped"),
(AgentState::Unknown("parked".to_owned()), "parked"),
] {
let row = ConvRow {
state,
..conv("id", "port the probe")
};
assert_eq!(help(&row), format!("{said}{CLICK}"));
}
let asking = ConvRow {
state: AgentState::Live,
attention: 2,
..conv("id", "port the probe")
};
assert_eq!(help(&asking), format!("asking, 2 waiting{CLICK}"));
}
#[test]
fn an_unobserved_state_is_qualified() {
let row = ConvRow {
uncertain: true,
..conv("id", "port the probe")
};
assert_eq!(
help(&row),
format!("at rest, as far as anyone has looked{CLICK}")
);
}
#[test]
fn a_failure_clause_stands_between_the_state_and_the_click() {
let row = ConvRow {
state: AgentState::Stopped,
uncertain: true,
failure: Some("no credential for provider row \"work\"".to_owned()),
..conv("id", "a refusing conversation")
};
assert_eq!(
help(&row),
format!(
"stopped, as far as anyone has looked · no credential for provider row \"work\"{CLICK}"
)
);
}