Lines
0 %
Functions
Branches
100 %
// -- -*- mode: rust -*-
//! Fetchers must treat a non-2xx response as an error, not as a body.
use nomisync_frontend::http::{fetch_get, fetch_json};
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
async fn missing_resource_is_an_error_not_a_body() {
let error = fetch_get("/nomisync-no-such-resource", None)
.await
.expect_err("a 404 must not parse as success");
assert!(error.as_string().is_some_and(|m| !m.is_empty()));
}
async fn json_fetcher_checks_the_status_too() {
let result = fetch_json("/nomisync-no-such-resource").await;
assert!(result.is_err());