From 12265e9237787d3cbf13cfb0939f9bd62c25fad1 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 21 Mar 2019 01:39:21 +0100 Subject: [PATCH] presence: Fix serialisation of priority. --- src/presence.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/presence.rs b/src/presence.rs index fba1773..c6a1a10 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -347,7 +347,11 @@ impl From 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"); + } }