1
// -- -*- mode: rust -*-
2
//! Fetchers must treat a non-2xx response as an error, not as a body.
3

            
4
use nomisync_frontend::http::{fetch_get, fetch_json};
5
use wasm_bindgen_test::*;
6

            
7
wasm_bindgen_test_configure!(run_in_browser);
8

            
9
#[wasm_bindgen_test]
10
async fn missing_resource_is_an_error_not_a_body() {
11
    let error = fetch_get("/nomisync-no-such-resource", None)
12
        .await
13
        .expect_err("a 404 must not parse as success");
14
    assert!(error.as_string().is_some_and(|m| !m.is_empty()));
15
}
16

            
17
#[wasm_bindgen_test]
18
async fn json_fetcher_checks_the_status_too() {
19
    let result = fetch_json("/nomisync-no-such-resource").await;
20
    assert!(result.is_err());
21
}