From ce49b918c685d8f8e5e518f09ebfa88851842785 Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Thu, 5 Dec 2019 21:41:43 +0100 Subject: [PATCH] Add serialization test for mam result and fin element --- xmpp-parsers/src/mam.rs | 58 ++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/xmpp-parsers/src/mam.rs b/xmpp-parsers/src/mam.rs index 7799dea..a8cea9c 100644 --- a/xmpp-parsers/src/mam.rs +++ b/xmpp-parsers/src/mam.rs @@ -392,26 +392,17 @@ mod tests { } #[test] - fn test_serialize_query_with() { + fn test_serialize_query_with_form() { let reference: Element = "urn:xmpp:mam:2juliet@capulet.lit" .parse() .unwrap(); - let form = DataForm { - type_: DataFormType::Submit, - form_type: Some(String::from(ns::MAM)), - title: None, - instructions: None, - fields: vec![Field { - var: String::from("with"), - type_: FieldType::TextSingle, - label: None, - required: false, - options: vec![], - values: vec![String::from("juliet@capulet.lit")], - media: vec![], - }], - }; + let elem: Element = "urn:xmpp:mam:2juliet@capulet.lit" + .parse() + .unwrap(); + + let form = DataForm::try_from(elem).unwrap(); + let foo = Query { queryid: None, node: None, @@ -424,11 +415,42 @@ mod tests { #[test] fn test_serialize_result() { - assert!(false); + let reference: Element = "" + .parse() + .unwrap(); + + let elem: Element = "" + .parse() + .unwrap(); + + let forwarded = Forwarded::try_from(elem).unwrap(); + + let result = Result_ { + id: String::from("28482-98726-73623"), + queryid: Some(QueryId(String::from("f27"))), + forwarded: forwarded, + }; + let serialized: Element = result.into(); + assert_eq!(serialized, reference); } #[test] fn test_serialize_fin() { - assert!(false); + let reference: Element = "28482-98726-7362309af3-cc343-b409f" + .parse() + .unwrap(); + + let elem: Element = "28482-98726-7362309af3-cc343-b409f" + .parse() + .unwrap(); + + let set = SetResult::try_from(elem).unwrap(); + + let fin = Fin { + set: set, + complete: Complete::default(), + }; + let serialized: Element = fin.into(); + assert_eq!(serialized, reference); } }