From 9fd45759584d2669101d0b40151a4b545a41f0e8 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Mon, 22 Apr 2024 21:01:25 +0200 Subject: [PATCH] Test roster query --- crates/proto-xmpp/src/roster.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/proto-xmpp/src/roster.rs b/crates/proto-xmpp/src/roster.rs index f7d0305..835cf94 100644 --- a/crates/proto-xmpp/src/roster.rs +++ b/crates/proto-xmpp/src/roster.rs @@ -38,3 +38,32 @@ impl ToXml for RosterQuery { events.push(Event::Empty(BytesStart::new(format!(r#"query xmlns="{}""#, XMLNS)))); } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::bind::{Jid, Name, Resource, Server}; + use crate::client::{Iq, IqType}; + + #[test] + fn test_parse() { + let input = + r#""#; + + let result: Iq = parse(input).unwrap(); + assert_eq!( + result, + Iq { + from: Option::from(Jid { + name: Option::from(Name("juliet".into())), + server: Server("example.com".into()), + resource: Option::from(Resource("balcony".into())) + }), + id: "bv1bs71f".to_string(), + to: None, + r#type: IqType::Get, + body: RosterQuery, + } + ) + } +}