helpers, disco: Add missing serialisation, and add a test.

This commit is contained in:
Emmanuel Gil Peyrot 2017-11-23 16:30:53 +00:00
parent 682bb34b0b
commit d78a0e6dae
2 changed files with 5 additions and 0 deletions

View file

@ -377,6 +377,8 @@ mod tests {
fn test_answers_items_result() { fn test_answers_items_result() {
let elem: Element = "<query xmlns='http://jabber.org/protocol/disco#items'><item jid='component'/><item jid='component2' node='test' name='A component'/></query>".parse().unwrap(); let elem: Element = "<query xmlns='http://jabber.org/protocol/disco#items'><item jid='component'/><item jid='component2' node='test' name='A component'/></query>".parse().unwrap();
let query = DiscoItemsResult::try_from(elem).unwrap(); let query = DiscoItemsResult::try_from(elem).unwrap();
let elem2 = Element::from(query);
let query = DiscoItemsResult::try_from(elem2).unwrap();
assert_eq!(query.items.len(), 2); assert_eq!(query.items.len(), 2);
assert_eq!(query.items[0].jid, Jid::from_str("component").unwrap()); assert_eq!(query.items[0].jid, Jid::from_str("component").unwrap());
assert_eq!(query.items[0].node, None); assert_eq!(query.items[0].node, None);

View file

@ -340,6 +340,9 @@ macro_rules! generate_element_with_children {
$( $(
.attr($attr_name, elem.$attr) .attr($attr_name, elem.$attr)
)* )*
$(
.append(elem.$child_ident)
)*
.build() .build()
} }
} }