diff --git a/client/src/dispatcher.rs b/client/src/dispatcher.rs index cd07a5a..7c1103c 100644 --- a/client/src/dispatcher.rs +++ b/client/src/dispatcher.rs @@ -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()); } }