receipts: Update to XEP-0184 version 1.4.0.
This commit is contained in:
parent
eac385700c
commit
89d24de302
3 changed files with 16 additions and 6 deletions
2
doap.xml
2
doap.xml
|
@ -235,7 +235,7 @@
|
||||||
<xmpp:SupportedXep>
|
<xmpp:SupportedXep>
|
||||||
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0184.html"/>
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0184.html"/>
|
||||||
<xmpp:status>complete</xmpp:status>
|
<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:since>0.1.0</xmpp:since>
|
||||||
</xmpp:SupportedXep>
|
</xmpp:SupportedXep>
|
||||||
</implements>
|
</implements>
|
||||||
|
|
|
@ -58,6 +58,7 @@ impl PubSubPayload for Data {}
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::hashes::Algo;
|
use crate::hashes::Algo;
|
||||||
|
#[cfg(not(feature = "disable-validation"))]
|
||||||
use crate::util::error::Error;
|
use crate::util::error::Error;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
|
@ -22,7 +22,7 @@ generate_element!(
|
||||||
Received, "received", RECEIPTS,
|
Received, "received", RECEIPTS,
|
||||||
attributes: [
|
attributes: [
|
||||||
/// The 'id' attribute of the received message.
|
/// 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 crate::ns;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
use crate::util::error::Error;
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -54,15 +55,23 @@ mod tests {
|
||||||
let elem: Element = "<request xmlns='urn:xmpp:receipts'/>".parse().unwrap();
|
let elem: Element = "<request xmlns='urn:xmpp:receipts'/>".parse().unwrap();
|
||||||
Request::try_from(elem).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'/>"
|
let elem: Element = "<received xmlns='urn:xmpp:receipts' id='coucou'/>"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Received::try_from(elem).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]
|
#[test]
|
||||||
fn test_serialise() {
|
fn test_serialise() {
|
||||||
let receipt = Request;
|
let receipt = Request;
|
||||||
|
@ -71,7 +80,7 @@ mod tests {
|
||||||
assert_eq!(elem.attrs().count(), 0);
|
assert_eq!(elem.attrs().count(), 0);
|
||||||
|
|
||||||
let receipt = Received {
|
let receipt = Received {
|
||||||
id: Some(String::from("coucou")),
|
id: String::from("coucou"),
|
||||||
};
|
};
|
||||||
let elem: Element = receipt.into();
|
let elem: Element = receipt.into();
|
||||||
assert!(elem.is("received", ns::RECEIPTS));
|
assert!(elem.is("received", ns::RECEIPTS));
|
||||||
|
|
Loading…
Reference in a new issue