Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
b57b36f81a
commit
41849edbb9
1 changed files with 43 additions and 0 deletions
43
src/lib.rs
43
src/lib.rs
|
@ -270,4 +270,47 @@ mod tests {
|
|||
);
|
||||
assert_eq!(parse_receive(buf2).unwrap().1, receive);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_spec() {
|
||||
let buf = r#"
|
||||
[Client] louise
|
||||
jid: louise@localhost
|
||||
password: password
|
||||
|
||||
-----
|
||||
|
||||
louise connects
|
||||
|
||||
louise sends:
|
||||
<presence to="some@room" />
|
||||
|
||||
louise receives:
|
||||
<message from="louise@localhost"
|
||||
/>
|
||||
|
||||
"#;
|
||||
|
||||
let mut accounts: HashMap<AccountName, Account> = HashMap::new();
|
||||
accounts.insert(String::from("louise"), get_account("louise"));
|
||||
|
||||
let xml1 = b"<presence to=\"some@room\" />\n\n";
|
||||
let xml2 = b"<message from=\"louise@localhost\"\n\t\t/>\n\n";
|
||||
|
||||
let actions = vec![
|
||||
Action::Connect(String::from("louise")),
|
||||
Action::Send(
|
||||
String::from("louise"),
|
||||
Element::from_reader_with_prefixes(&xml1[..], String::from(DEFAULT_NS)).unwrap(),
|
||||
),
|
||||
Action::Receive(
|
||||
String::from("louise"),
|
||||
Element::from_reader_with_prefixes(&xml2[..], String::from(DEFAULT_NS)).unwrap(),
|
||||
),
|
||||
];
|
||||
|
||||
let spec = Spec { accounts, actions };
|
||||
|
||||
assert_eq!(parse_spec(buf), Ok(spec));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue