Browse Source

Improve tests on Dispatcher.

wip
Titouan Rigoudy 4 years ago
parent
commit
34ebc39bb1
1 changed files with 40 additions and 9 deletions
  1. +40
    -9
      client/src/dispatcher.rs

+ 40
- 9
client/src/dispatcher.rs View File

@ -94,6 +94,9 @@ impl Dispatcher {
#[cfg(test)]
mod tests {
use crate::control;
use crate::dispatcher::Message;
use solstice_proto::server::{self, ServerResponse};
use super::*;
@ -103,20 +106,48 @@ mod tests {
}
#[test]
fn dispatcher_privileged_users_response() {
fn does_not_dispatch_unhandled_response() {
assert!(Dispatcher::new()
.dispatch(into_message(server::PrivilegedUsersResponse {
users: vec!["foo".to_string(), "bar".to_string(), "baz".to_string()],
}))
.dispatch(Message::ServerResponse(
server::LoginResponse::LoginFail {
reason: "bleep bloop".to_string(),
}
.into()
))
.is_none());
}
#[test]
fn dispatches_privileged_users_response() {
assert!(Dispatcher::new()
.dispatch(Message::ServerResponse(
server::PrivilegedUsersResponse {
users: vec!["foo".to_string(), "bar".to_string(), "baz".to_string()],
}
.into()
))
.is_some());
}
#[test]
fn dispatcher_unhandled_response() {
fn dispatches_room_list_response() {
assert!(Dispatcher::new()
.dispatch(into_message(server::LoginResponse::LoginFail {
reason: "bleep bloop".to_string(),
},))
.is_none());
.dispatch(Message::ServerResponse(
server::RoomListResponse {
rooms: Vec::new(),
owned_private_rooms: Vec::new(),
other_private_rooms: Vec::new(),
operated_private_room_names: Vec::new(),
}
.into()
))
.is_some());
}
#[test]
fn dispatches_room_list_request() {
assert!(Dispatcher::new()
.dispatch(Message::ControlRequest(control::Request::RoomListRequest))
.is_some());
}
}

Loading…
Cancel
Save