half of the tests are set for the json_to_state

This commit is contained in:
Nickiel12 2021-12-19 00:43:16 -08:00
parent fa315fa9a3
commit 1f87e1a1b3

View file

@ -0,0 +1,59 @@
use crate::modules::stream_states::{state_update::StateUpdate, enums::Scenes};
#[test]
fn test_json_to_state_update() {
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Scene_Camera\"}"
).unwrap()), StateUpdate::Scene(Scenes::Camera));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Scene_Screen\"}"
).unwrap()), StateUpdate::Scene(Scenes::Screen));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Augmented\", \"data\": true}"
).unwrap()), StateUpdate::SceneIsAugmented(true));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Auto_Change_To_Camera\", \"data\": true}"
).unwrap()), StateUpdate::TimerCanRun(true));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Auto_Change_To_Camera\", \"data\": false}"
).unwrap()), StateUpdate::TimerCanRun(false));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Change_With_Clicker\", \"data\": true}"
).unwrap()), StateUpdate::ChangeSceneOnChangeSlideHotkey(true));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Change_With_Clicker\", \"data\": false}"
).unwrap()), StateUpdate::ChangeSceneOnChangeSlideHotkey(false));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Toggle_Computer_Volume\", \"data\": true}"
).unwrap()), StateUpdate::ComputerSoundIsOn(true));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Toggle_Computer_Volume\", \"data\": false}"
).unwrap()), StateUpdate::ComputerSoundIsOn(false));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Toggle_Stream_Volume\", \"data\": true}"
).unwrap()), StateUpdate::StreamIsMuted(true));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Toggle_Stream_Volume\", \"data\": false}"
).unwrap()), StateUpdate::StreamIsMuted(false));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Media_Pause_Play\", \"data\": true}"
).unwrap()), StateUpdate::ComputerMediaDoPause(true));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"button\", \"button\": \"Media_Pause_Play\", \"data\": false}"
).unwrap()), StateUpdate::ComputerMediaDoPause(false));
}