use crate::web::{MyResponse, RequestOrigin};
use rocket_codegen::get;
use rocket_i18n::I18n;

#[get("/")]
pub fn root(origin: RequestOrigin, i18n: I18n) -> MyResponse {
    MyResponse::ok_bare("index", i18n, origin)
}

#[cfg(test)]
mod tests {
    use crate::routes::tests::common::*;
    use ::rocket::http::{ContentType, Status};
    use ::rocket::local::blocking::Client;
    use rstest::rstest;
    use tempfile::TempDir;

    mod get_root {
        use super::*;

        const URI: &str = "/";

        #[rstest]
        fn landing_page_is_visible(#[from(client)] (_tmpdir, client): (TempDir, Client)) {
            assert::response(
                client.get(URI).dispatch(),
                Status::Ok,
                ContentType::HTML,
                "Hagrid",
            );
        }
    }
}
