xmpp-parsers: Add a MIX serialisation test.
This commit is contained in:
parent
820fbbf08e
commit
048e49f786
1 changed files with 41 additions and 0 deletions
|
|
@ -348,4 +348,45 @@ mod tests {
|
||||||
let destroy = Destroy::try_from(elem).unwrap();
|
let destroy = Destroy::try_from(elem).unwrap();
|
||||||
assert_eq!(destroy.channel.0, "coucou");
|
assert_eq!(destroy.channel.0, "coucou");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialise() {
|
||||||
|
let elem: Element = Join::from_nick_and_nodes("coucou", &["foo", "bar"]).into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(xml, "<join xmlns=\"urn:xmpp:mix:core:1\"><nick xmlns=\"urn:xmpp:mix:core:1\">coucou</nick><subscribe xmlns=\"urn:xmpp:mix:core:1\" node=\"foo\"/><subscribe xmlns=\"urn:xmpp:mix:core:1\" node=\"bar\"/></join>");
|
||||||
|
|
||||||
|
let elem: Element = UpdateSubscription::from_nodes(&["foo", "bar"]).into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(xml, "<update-subscription xmlns=\"urn:xmpp:mix:core:1\"><subscribe xmlns=\"urn:xmpp:mix:core:1\" node=\"foo\"/><subscribe xmlns=\"urn:xmpp:mix:core:1\" node=\"bar\"/></update-subscription>");
|
||||||
|
|
||||||
|
let elem: Element = Leave.into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(xml, "<leave xmlns=\"urn:xmpp:mix:core:1\"/>");
|
||||||
|
|
||||||
|
let elem: Element = SetNick::new("coucou").into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(xml, "<setnick xmlns=\"urn:xmpp:mix:core:1\"><nick xmlns=\"urn:xmpp:mix:core:1\">coucou</nick></setnick>");
|
||||||
|
|
||||||
|
let elem: Element = Mix::new("coucou", "coucou@example").into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(xml, "<mix xmlns=\"urn:xmpp:mix:core:1\"><nick xmlns=\"urn:xmpp:mix:core:1\">coucou</nick><jid xmlns=\"urn:xmpp:mix:core:1\">coucou@example</jid></mix>");
|
||||||
|
|
||||||
|
let elem: Element = Create::new().into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(xml, "<create xmlns=\"urn:xmpp:mix:core:1\"/>");
|
||||||
|
|
||||||
|
let elem: Element = Create::from_channel_id("coucou").into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(
|
||||||
|
xml,
|
||||||
|
"<create xmlns=\"urn:xmpp:mix:core:1\" channel=\"coucou\"/>"
|
||||||
|
);
|
||||||
|
|
||||||
|
let elem: Element = Destroy::new("coucou").into();
|
||||||
|
let xml = String::from(&elem);
|
||||||
|
assert_eq!(
|
||||||
|
xml,
|
||||||
|
"<destroy xmlns=\"urn:xmpp:mix:core:1\" channel=\"coucou\"/>"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue