Change summary
xmpp-parsers/src/mam.rs | 4 +-
xmpp-parsers/src/pubsub/pubsub.rs | 45 ++++++++++++++++++++++++--------
2 files changed, 36 insertions(+), 13 deletions(-)
Detailed changes
@@ -403,13 +403,13 @@ mod tests {
let form = DataForm::try_from(elem).unwrap();
- let foo = Query {
+ let query = Query {
queryid: None,
node: None,
set: None,
form: Some(form),
};
- let serialized: Element = foo.into();
+ let serialized: Element = query.into();
assert_eq!(serialized, reference);
}
@@ -519,6 +519,8 @@ impl From<PubSub> for Element {
mod tests {
use super::*;
use crate::data_forms::{DataForm, DataFormType, Field, FieldType};
+ use jid::FullJid;
+ use std::str::FromStr;
#[test]
fn create() {
@@ -690,23 +692,44 @@ mod tests {
assert_eq!(subscribe_options2.required, true);
}
- #[test]
- fn test_serialize_configure() {
- assert!(false);
- }
-
#[test]
fn test_serialize_options() {
- assert!(false);
+ let reference: Element = "<options xmlns='http://jabber.org/protocol/pubsub' jid='juliet@capulet.lit/balcony'><x xmlns='jabber:x:data' type='submit'/></options>"
+ .parse()
+ .unwrap();
+
+ let elem: Element = "<x xmlns='jabber:x:data' type='submit'/>"
+ .parse()
+ .unwrap();
+
+ let form = DataForm::try_from(elem).unwrap();
+
+ let options = Options {
+ jid: Jid::Full(FullJid::from_str("juliet@capulet.lit/balcony").unwrap()),
+ node: None,
+ subid: None,
+ form: Some(form),
+ };
+ let serialized: Element = options.into();
+ assert_eq!(serialized, reference);
}
#[test]
fn test_serialize_publish_options() {
- assert!(false);
- }
+ let reference: Element = "<publish-options xmlns='http://jabber.org/protocol/pubsub'><x xmlns='jabber:x:data' type='submit'/></publish-options>"
+ .parse()
+ .unwrap();
- #[test]
- fn test_serialize_subscriptions() {
- assert!(false);
+ let elem: Element = "<x xmlns='jabber:x:data' type='submit'/>"
+ .parse()
+ .unwrap();
+
+ let form = DataForm::try_from(elem).unwrap();
+
+ let options = PublishOptions {
+ form: Some(form),
+ };
+ let serialized: Element = options.into();
+ assert_eq!(serialized, reference);
}
}