From 8d41959497c2d9ca5683925af5f1f1cab4d54c41 Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Wed, 27 Nov 2019 18:16:33 +0100 Subject: [PATCH] jingle: Add test on serialisation --- xmpp-parsers/src/jingle.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/xmpp-parsers/src/jingle.rs b/xmpp-parsers/src/jingle.rs index 8d64a220..5921d887 100644 --- a/xmpp-parsers/src/jingle.rs +++ b/xmpp-parsers/src/jingle.rs @@ -858,4 +858,39 @@ mod tests { }; assert_eq!(message, "Text element present twice for the same xml:lang."); } + + #[test] + fn test_serialize_jingle() { + let reference: Element = "" + .parse() + .unwrap(); + + let jingle = Jingle { + action: Action::SessionInitiate, + initiator: None, + responder: None, + sid: SessionId(String::from("a73sjjvkla37jfea")), + contents: vec![Content { + creator: Creator::Initiator, + disposition: Disposition::default(), + name: ContentId(String::from("this-is-a-stub")), + senders: Senders::default(), + description: Some(Description::Unknown( + Element::builder("description") + .ns("urn:xmpp:jingle:apps:stub:0") + .build(), + )), + transport: Some(Transport::Unknown( + Element::builder("transport") + .ns("urn:xmpp:jingle:transports:stub:0") + .build(), + )), + security: None, + }], + reason: None, + other: vec![], + }; + let serialized: Element = jingle.into(); + assert_eq!(serialized, reference); + } }