From 4094c1ceb832d4e2616e69b4de092b90c755e65b Mon Sep 17 00:00:00 2001 From: Waffle Date: Thu, 5 Sep 2019 19:00:26 +0300 Subject: [PATCH] Add serialization tests for `ChatId` --- src/core/requests/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/core/requests/mod.rs b/src/core/requests/mod.rs index 64da515b..3144daad 100644 --- a/src/core/requests/mod.rs +++ b/src/core/requests/mod.rs @@ -64,6 +64,27 @@ pub enum ChatId { ChannelUsername(String), } +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn chat_id_id_serialization() { + let expected_json = String::from(r#"123456"#); + let actual_json = serde_json::to_string(&ChatId::Id(123456)).unwrap(); + + assert_eq!(expected_json, actual_json) + } + + #[test] + fn chat_id_channel_username_serialization() { + let expected_json = String::from(r#""@username""#); + let actual_json = serde_json::to_string(&ChatId::ChannelUsername(String::from("@username"))).unwrap(); + + assert_eq!(expected_json, actual_json) + } +} + pub mod get_me; pub mod send_message; pub mod forward_message;