use crate::types::*;
#[test]
fn poll() {
insta::assert_json_snapshot!(Poll::from(
RegularPoll::new("poll-id", "Rust?")
.with_is_anonymous(true)
.with_is_closed(true)
.with_description("test")
.with_options([PollOption::new("1", "Yes", 1000), PollOption::new("2", "No", 0)])
.with_total_voter_count(1000),
));
}
#[test]
fn quiz() {
insta::assert_json_snapshot!(Poll::from(
Quiz::new("poll-id", "Rust?")
.with_correct_option_ids([0])
.with_explanation(Text::from("text").with_entities(vec![TextEntity::bold(0..2)].into_iter().collect()))
.with_is_anonymous(true)
.with_is_closed(true)
.with_description(Text::from("test").with_entities(vec![TextEntity::bold(0..2)].into_iter().collect()))
.with_options([PollOption::new("1", "Yes", 1000), PollOption::new("2", "No", 0)])
.with_total_voter_count(100),
));
}
#[test]
fn poll_answer() {
insta::assert_json_snapshot!(PollAnswer::new([0], "poll-id", User::new(1, "User", false)));
}
#[test]
fn poll_answer_voter() {
insta::assert_json_snapshot!(PollAnswerVoter::from(User::new(1, "User", false)));
insta::assert_json_snapshot!(PollAnswerVoter::from(Chat::Channel(
ChannelChat::new(1, "test-channel").with_username("test_channel"),
)));
}
#[test]
fn send_quiz() {
let method = SendQuiz::new(1, "Q", [0], ["X"]);
assert_payload_eq!(POST JSON "sendPoll" => method.clone());
let method = method.with_question_entities([TextEntity::bold(0..1)]);
assert_payload_eq!(POST JSON "sendPoll" => method.clone());
let method = method.with_question_parse_mode(ParseMode::MarkdownV2);
assert_payload_eq!(POST JSON "sendPoll" => method);
let method = SendQuiz::new(1, "Q", [0], ["O1", "O2"])
.with_allow_adding_options(true)
.with_allow_paid_broadcast(true)
.with_allows_multiple_answers(true)
.with_allows_revoting(false)
.with_business_connection_id("id")
.with_description("test")
.with_description_parse_mode(ParseMode::MarkdownV2)
.with_disable_notification(true)
.with_hide_results_until_closes(true)
.with_is_anonymous(false)
.with_is_closed(false)
.with_message_effect_id("effect-id")
.with_message_thread_id(1)
.with_protect_content(true)
.with_reply_markup(ForceReply::new(true))
.with_reply_parameters(ReplyParameters::new(1))
.with_shuffle_options(true);
assert_payload_eq!(POST JSON "sendPoll" => method);
}
#[test]
fn send_poll() {
let method = SendPoll::new(1, "Q", ["X"]);
assert_payload_eq!(POST JSON "sendPoll" => method.clone());
let method = method.with_question_entities([TextEntity::bold(0..1)]);
assert_payload_eq!(POST JSON "sendPoll" => method.clone());
let method = method.with_question_parse_mode(ParseMode::MarkdownV2);
assert_payload_eq!(POST JSON "sendPoll" => method);
let method = SendPoll::new(1, "Q", ["O1", "O2"])
.with_allow_adding_options(true)
.with_allow_paid_broadcast(true)
.with_allows_multiple_answers(true)
.with_allows_revoting(true)
.with_business_connection_id("id")
.with_description("test")
.with_description_entities([TextEntity::bold(0..2)])
.with_disable_notification(true)
.with_hide_results_until_closes(true)
.with_is_anonymous(false)
.with_is_closed(false)
.with_message_effect_id("effect-id")
.with_message_thread_id(1)
.with_protect_content(true)
.with_reply_markup(ForceReply::new(true))
.with_reply_parameters(ReplyParameters::new(1))
.with_shuffle_options(true);
assert_payload_eq!(POST JSON "sendPoll" => method);
}
#[test]
fn stop_poll() {
let method = StopPoll::new(1, 2)
.with_business_connection_id("c-id")
.with_reply_markup([[InlineKeyboardButton::for_url("text", "url")]]);
assert_payload_eq!(POST JSON "stopPoll" => method);
}