#![allow(unused_imports)]
use super::*;

#[test]
fn test_builder_core_routes() {
    let spec = OpenApiBuilder::new("Better Auth", "0.1.0")
        .description("Authentication API")
        .core_routes()
        .build();

    assert_eq!(spec.openapi, "3.1.0");
    assert_eq!(spec.info.title, "Better Auth");
    assert!(spec.paths.contains_key("/health"));
    assert!(spec.paths.contains_key("/ok"));
    assert!(spec.paths.contains_key("/error"));
    assert!(spec.paths.contains_key("/update-user"));
    assert!(spec.paths.contains_key("/delete-user"));

    let health_path = &spec.paths["/health"];
    assert!(health_path.contains_key("get"));
    assert_eq!(health_path["get"].operation_id, "health");

    // /ok should have a GET operation
    let ok_path = &spec.paths["/ok"];
    assert!(ok_path.contains_key("get"));
    assert_eq!(ok_path["get"].operation_id, "ok");
}

#[test]
fn test_builder_custom_route() {
    let spec = OpenApiBuilder::new("Test", "1.0.0")
        .route(
            &HttpMethod::Post,
            "/sign-in/email",
            "sign_in_email",
            "email-password",
        )
        .build();

    let path = &spec.paths["/sign-in/email"];
    assert!(path.contains_key("post"));
    assert_eq!(path["post"].tags, vec!["email-password"]);
}

#[test]
fn test_spec_to_json() {
    let spec = OpenApiBuilder::new("Test", "1.0.0").core_routes().build();

    let json = spec.to_json().unwrap();
    assert!(json.contains("\"openapi\": \"3.1.0\""));
    assert!(json.contains("\"/health\""));
    assert!(json.contains("\"/ok\""));
}

#[test]
fn test_spec_to_value() {
    let spec = OpenApiBuilder::new("Test", "1.0.0").core_routes().build();

    let value = spec.to_value().unwrap();
    assert_eq!(value["openapi"], "3.1.0");
    assert!(value["paths"]["/health"]["get"]["operationId"].is_string());
    assert!(value["paths"]["/ok"]["get"]["operationId"].is_string());
}
