use crate::channels::telegram::ephemeral::{build_body, build_rich_body, receiver_for};
use teloxide::types::{MessageId, ThreadId};
#[test]
fn dm_never_scopes_a_reply() {
assert_eq!(receiver_for(true, 12345), None);
}
#[test]
fn group_scopes_the_reply_to_the_invoker() {
assert_eq!(receiver_for(false, 12345), Some(12345));
}
#[test]
fn body_carries_receiver_user_id() {
let body = build_body(-100200, None, 12345, "hello", false);
assert_eq!(body["chat_id"], -100200);
assert_eq!(body["text"], "hello");
assert_eq!(body["receiver_user_id"], 12345);
}
#[test]
fn plain_body_has_no_parse_mode() {
let body = build_body(-100200, None, 12345, "a < b & c", false);
assert!(body.get("parse_mode").is_none());
}
#[test]
fn html_body_sets_parse_mode() {
let body = build_body(-100200, None, 12345, "<b>hi</b>", true);
assert_eq!(body["parse_mode"], "HTML");
}
#[test]
fn rich_body_is_the_public_body_plus_the_receiver() {
let public = crate::channels::telegram::rich::api::build_body(-100200, None, "# hi");
let scoped = build_rich_body(-100200, None, 12345, "# hi");
assert_eq!(scoped["rich_message"], public["rich_message"]);
assert_eq!(scoped["chat_id"], public["chat_id"]);
assert_eq!(scoped["receiver_user_id"], 12345);
}
#[test]
fn rich_body_keeps_the_forum_topic() {
let body = build_rich_body(-100200, Some(ThreadId(MessageId(77))), 12345, "# hi");
assert_eq!(body["message_thread_id"], 77);
assert_eq!(body["receiver_user_id"], 12345);
}
#[test]
fn thread_id_targets_the_forum_topic() {
let body = build_body(-100200, Some(ThreadId(MessageId(77))), 12345, "hi", true);
assert_eq!(body["message_thread_id"], 77);
}
#[test]
fn no_thread_id_omits_the_field() {
let body = build_body(-100200, None, 12345, "hi", true);
assert!(body.get("message_thread_id").is_none());
}