use crate::channels::commands::{format_help, md_table};
use crate::channels::telegram::rich::markdown_to_html;
#[test]
fn help_is_authored_as_heading_plus_table() {
let help = format_help();
assert!(help.contains("# 📖 Available Commands"), "needs a heading");
assert!(
help.contains("| Command | Description |"),
"needs a markdown table header"
);
assert!(help.contains("| --- |"), "needs a GFM separator row");
}
#[test]
fn help_renders_commands_on_separate_lines() {
let html = markdown_to_html(&format_help());
assert!(html.contains("/new"));
assert!(html.contains("/cd"));
let new_pos = html.find("/new").unwrap();
let cd_pos = html.find("/cd").unwrap();
assert!(
html[new_pos..cd_pos].contains('\n'),
"commands collapsed onto one line: {:?}",
&html[new_pos..cd_pos]
);
assert!(html.contains("<b>") && html.contains("Available Commands"));
}
#[test]
fn help_qualifies_for_native_rich_rendering() {
assert!(
crate::channels::telegram::rich::has_rich_structure(&format_help()),
"help must contain a table/heading so it routes to native rich"
);
}
#[test]
fn md_table_emits_gfm_with_separator() {
let t = md_table(&["A", "B"], &[vec!["1".into(), "2".into()]]);
assert!(t.contains("| A | B |"));
assert!(t.contains("| --- |"));
assert!(t.contains("| 1 | 2 |"));
assert_eq!(md_table(&["A"], &[]), "");
}
#[test]
fn md_table_neutralizes_pipes_and_newlines_in_cells() {
let t = md_table(&["X"], &[vec!["a|b\nc".into()]]);
assert!(!t.contains("a|b"), "cell pipe leaked: {t:?}");
assert_eq!(t.lines().count(), 3, "extra rows from cell newline: {t:?}");
assert!(
t.lines().any(|l| l.contains("a b c")),
"cell pipe/newline should collapse to spaces: {t:?}"
);
}