presence: Fix serialisation of priority.
This commit is contained in:
parent
98c4c5b901
commit
12265e9237
1 changed files with 16 additions and 1 deletions
|
|
@ -347,7 +347,11 @@ impl From<Presence> for Element {
|
||||||
.append(if presence.priority == 0 {
|
.append(if presence.priority == 0 {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(format!("{}", presence.priority))
|
Some(
|
||||||
|
Element::builder("priority")
|
||||||
|
.append(format!("{}", presence.priority))
|
||||||
|
.build()
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.append(presence.payloads)
|
.append(presence.payloads)
|
||||||
.build()
|
.build()
|
||||||
|
|
@ -622,4 +626,15 @@ mod tests {
|
||||||
assert!(elem.is("presence", ns::DEFAULT_NS));
|
assert!(elem.is("presence", ns::DEFAULT_NS));
|
||||||
assert!(elem.children().next().unwrap().is("status", 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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue