From 1f87e1a1b35d39dba089caa7e66ff9e617bc499e Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Sun, 19 Dec 2021 00:43:16 -0800 Subject: [PATCH] half of the tests are set for the json_to_state --- src/tests/state_update_tests.rs | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/tests/state_update_tests.rs b/src/tests/state_update_tests.rs index e69de29..3070112 100644 --- a/src/tests/state_update_tests.rs +++ b/src/tests/state_update_tests.rs @@ -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)); + +} \ No newline at end of file