half of the tests are set for the json_to_state
This commit is contained in:
parent
fa315fa9a3
commit
1f87e1a1b3
1 changed files with 59 additions and 0 deletions
|
@ -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));
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue