presence: Fix serialisation of priority.

This commit is contained in:
Emmanuel Gil Peyrot 2019-03-21 01:39:21 +01:00
parent 98c4c5b901
commit 12265e9237

View file

@ -347,7 +347,11 @@ impl From<Presence> for Element {
.append(if presence.priority == 0 {
None
} else {
Some(format!("{}", presence.priority))
Some(
Element::builder("priority")
.append(format!("{}", presence.priority))
.build()
)
})
.append(presence.payloads)
.build()
@ -622,4 +626,15 @@ mod tests {
assert!(elem.is("presence", ns::DEFAULT_NS));
assert!(elem.children().next().unwrap().is("status", ns::DEFAULT_NS));
}
#[test]
fn test_serialise_priority() {
let presence = Presence::new(Type::None)
.with_priority(42);
let elem: Element = presence.into();
assert!(elem.is("presence", ns::DEFAULT_NS));
let priority = elem.children().next().unwrap();
assert!(priority.is("priority", ns::DEFAULT_NS));
assert_eq!(priority.text(), "42");
}
}