use crate::channels::telegram::rich::api::build_body;
use crate::channels::telegram::rich::{contains_task_list, has_rich_structure};
use teloxide::types::{MessageId, ThreadId};
#[test]
fn task_list_asterisk_prefix_detected() {
assert!(contains_task_list("* [ ] star task\n* [x] done"));
}
#[test]
fn task_list_plus_prefix_detected() {
assert!(contains_task_list("+ [ ] plus task"));
}
#[test]
fn task_list_mixed_prefixes() {
assert!(contains_task_list("- [ ] dash\n* [x] star\n+ [ ] plus"));
}
#[test]
fn task_list_indented_detected() {
assert!(contains_task_list(" - [ ] indented"));
}
#[test]
fn rich_structure_ordered_list_detected() {
assert!(has_rich_structure("1. first\n2. second\n3. third"));
}
#[test]
fn rich_structure_empty_text_false() {
assert!(!has_rich_structure(""));
}
#[test]
fn rich_structure_whitespace_only_false() {
assert!(!has_rich_structure(" \n \n "));
}
#[test]
fn rich_request_body_with_thread_id() {
let body = build_body(99, Some(ThreadId(MessageId(42))), "| A |\n| - |\n| 1 |");
assert_eq!(body["chat_id"], 99);
assert_eq!(body["message_thread_id"], 42);
assert_eq!(body["rich_message"]["markdown"], "| A |\n| - |\n| 1 |");
}
#[test]
fn rich_request_body_without_thread_id() {
let body = build_body(100, None, "hello");
assert_eq!(body["chat_id"], 100);
assert!(body.get("message_thread_id").is_none());
assert_eq!(body["rich_message"]["markdown"], "hello");
}