use pretty_assertions::assert_eq;
use super::*;
const READY: SetupState = SetupState { signed_in: true };
const SIGNED_OUT: SetupState = SetupState { signed_in: false };
#[test]
fn only_a_signed_out_session_adds_a_headline() {
let cases = [(READY, false), (SIGNED_OUT, true)];
for (setup, expected) in cases {
assert_eq!(
setup.headline().is_some(),
expected,
"headline presence for {setup:?}"
);
}
}
#[test]
fn login_is_the_next_step_exactly_while_signed_out() {
let cases = [(READY, 0), (SIGNED_OUT, 1)];
for (setup, expected) in cases {
let next_steps = setup
.hints(HeaderHints::Shown)
.iter()
.filter(|hint| hint.tone == HintTone::NextStep)
.count();
assert_eq!(next_steps, expected, "next-step hints for {setup:?}");
if expected > 0 {
assert_eq!(
setup
.hints(HeaderHints::Shown)
.first()
.map(|hint| hint.tone),
Some(HintTone::NextStep),
"the next step must lead the hint block for {setup:?}"
);
}
}
}
#[test]
fn hidden_header_hints_keep_the_signed_out_next_step() {
assert_eq!(READY.hints(HeaderHints::Hidden), &[] as &[Hint]);
assert_eq!(
SIGNED_OUT.hints(HeaderHints::Hidden),
SIGNED_OUT.hints(HeaderHints::Shown)
);
}