Test roster query

This commit is contained in:
Mikhail 2024-04-22 21:01:25 +02:00
parent 1fbf9c24eb
commit 9fd4575958
1 changed files with 29 additions and 0 deletions

View File

@ -38,3 +38,32 @@ impl ToXml for RosterQuery {
events.push(Event::Empty(BytesStart::new(format!(r#"query xmlns="{}""#, XMLNS)))); 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#"<iq from='juliet@example.com/balcony' id='bv1bs71f' type='get'><query xmlns='jabber:iq:roster'/></iq>"#;
let result: Iq<RosterQuery> = 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,
}
)
}
}