use axum::response::{IntoResponse, Json};
use markbase::command::{get_commands, post_command};
use serde_json::json;

#[tokio::test]
async fn test_post_command_basic() {
    let body = json!({"cmd": "test_cmd", "val": "test_value"});
    let response = post_command(Json(body)).await;

    let response_json = response.into_response();
    //驗證響應狀態碼
    assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}

#[tokio::test]
async fn test_post_command_voice() {
    let body = json!({"cmd": "test_voice", "val": "zh_TW", "out": "Display Audio"});
    let response = post_command(Json(body)).await;

    let response_json = response.into_response();
    assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}

#[tokio::test]
async fn test_post_command_vol_up() {
    let body = json!({"cmd": "vol_up"});
    let response = post_command(Json(body)).await;

    let response_json = response.into_response();
    assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}

#[tokio::test]
async fn test_post_command_vol_down() {
    let body = json!({"cmd": "vol_down"});
    let response = post_command(Json(body)).await;

    let response_json = response.into_response();
    assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}

#[tokio::test]
async fn test_get_commands_empty() {
    let response = get_commands().await;
    let response_json = response.into_response();

    assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}
