diff --git a/src/mam.rs b/src/mam.rs index 416aefc9..4c0441be 100644 --- a/src/mam.rs +++ b/src/mam.rs @@ -239,45 +239,126 @@ pub fn serialise_prefs(prefs: &Prefs) -> Element { #[cfg(test)] mod tests { - /* use minidom::Element; use error::Error; use mam; #[test] - fn test_simple() { - let elem: Element = "".parse().unwrap(); + fn test_query() { + let elem: Element = "".parse().unwrap(); mam::parse_query(&elem).unwrap(); } #[test] - fn test_invalid_child() { - let elem: Element = "".parse().unwrap(); - let error = mam::parse_query(&elem).unwrap_err(); - let message = match error { - Error::ParseError(string) => string, - _ => panic!(), - }; - assert_eq!(message, "Unknown child in replace element."); + fn test_result() { + let elem: Element = r#" + + + + + Hail to thee + + + +"#.parse().unwrap(); + mam::parse_result(&elem).unwrap(); } #[test] - fn test_invalid_id() { - let elem: Element = "".parse().unwrap(); + fn test_fin() { + let elem: Element = r#" + + + 28482-98726-73623 + 09af3-cc343-b409f + + +"#.parse().unwrap(); + mam::parse_fin(&elem).unwrap(); + } + + #[test] + fn test_query_x() { + let elem: Element = r#" + + + + urn:xmpp:mam:2 + + + juliet@capulet.lit + + + +"#.parse().unwrap(); + mam::parse_query(&elem).unwrap(); + } + + #[test] + fn test_query_x_set() { + let elem: Element = r#" + + + + urn:xmpp:mam:2 + + + 2010-08-07T00:00:00Z + + + + 10 + + +"#.parse().unwrap(); + mam::parse_query(&elem).unwrap(); + } + + #[test] + fn test_prefs_get() { + let elem: Element = "".parse().unwrap(); + mam::parse_prefs(&elem).unwrap(); + + let elem: Element = r#" + + + + +"#.parse().unwrap(); + mam::parse_prefs(&elem).unwrap(); + } + + #[test] + fn test_prefs_result() { + let elem: Element = r#" + + + romeo@montague.lit + + + montague@montague.lit + + +"#.parse().unwrap(); + mam::parse_prefs(&elem).unwrap(); + } + + #[test] + fn test_invalid_child() { + let elem: Element = "".parse().unwrap(); let error = mam::parse_query(&elem).unwrap_err(); let message = match error { Error::ParseError(string) => string, _ => panic!(), }; - assert_eq!(message, "No 'id' attribute present in replace."); + assert_eq!(message, "Unknown child in query element."); } #[test] fn test_serialise() { - let elem: Element = "".parse().unwrap(); - let replace = mam::Query { id: String::from("coucou") }; - let elem2 = mam::serialise(&replace); + let elem: Element = "".parse().unwrap(); + let replace = mam::Query { queryid: None, node: None, form: None, set: None }; + let elem2 = mam::serialise_query(&replace); assert_eq!(elem, elem2); } - */ }