receipts: Update to XEP-0184 version 1.4.0.

This commit is contained in:
Emmanuel Gil Peyrot 2019-09-20 01:41:30 +02:00
parent eac385700c
commit 89d24de302
3 changed files with 16 additions and 6 deletions

View file

@ -235,7 +235,7 @@
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0184.html"/>
<xmpp:status>complete</xmpp:status>
<xmpp:version>1.3.0</xmpp:version>
<xmpp:version>1.4.0</xmpp:version>
<xmpp:since>0.1.0</xmpp:since>
</xmpp:SupportedXep>
</implements>

View file

@ -58,6 +58,7 @@ impl PubSubPayload for Data {}
mod tests {
use super::*;
use crate::hashes::Algo;
#[cfg(not(feature = "disable-validation"))]
use crate::util::error::Error;
use minidom::Element;
use std::convert::TryFrom;

View file

@ -22,7 +22,7 @@ generate_element!(
Received, "received", RECEIPTS,
attributes: [
/// The 'id' attribute of the received message.
id: Option<String> = "id",
id: Required<String> = "id",
]
);
@ -34,6 +34,7 @@ mod tests {
use crate::ns;
use minidom::Element;
use std::convert::TryFrom;
use crate::util::error::Error;
#[cfg(target_pointer_width = "32")]
#[test]
@ -54,15 +55,23 @@ mod tests {
let elem: Element = "<request xmlns='urn:xmpp:receipts'/>".parse().unwrap();
Request::try_from(elem).unwrap();
let elem: Element = "<received xmlns='urn:xmpp:receipts'/>".parse().unwrap();
Received::try_from(elem).unwrap();
let elem: Element = "<received xmlns='urn:xmpp:receipts' id='coucou'/>"
.parse()
.unwrap();
Received::try_from(elem).unwrap();
}
#[test]
fn test_missing_id() {
let elem: Element = "<received xmlns='urn:xmpp:receipts'/>".parse().unwrap();
let error = Received::try_from(elem).unwrap_err();
let message = match error {
Error::ParseError(string) => string,
_ => panic!(),
};
assert_eq!(message, "Required attribute 'id' missing.");
}
#[test]
fn test_serialise() {
let receipt = Request;
@ -71,7 +80,7 @@ mod tests {
assert_eq!(elem.attrs().count(), 0);
let receipt = Received {
id: Some(String::from("coucou")),
id: String::from("coucou"),
};
let elem: Element = receipt.into();
assert!(elem.is("received", ns::RECEIPTS));