Skip to content

Commit

Permalink
Extract load tokenizer func
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma-andex committed Jan 4, 2024
1 parent 44e19bb commit 6e316ea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use web_sys::{Request, RequestInit, RequestMode, Response};

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
async fn pass() -> Result<(), JsValue> {
async fn load_json(url: &str) -> Result<JsValue, JsValue> {
let mut opts = RequestInit::new();
opts.method("GET");
opts.mode(RequestMode::Cors);

let url = "http://localhost:45678/test.json";
// let url = "http://localhost:45678/tokenizer.json";

let request = Request::new_with_str_and_init(&url, &opts)?;

Expand All @@ -33,6 +32,14 @@ async fn pass() -> Result<(), JsValue> {
// Convert this other `Promise` into a rust `Future`.
let json = JsFuture::from(resp.json()?).await?;

Ok(json)
}
#[wasm_bindgen_test]
async fn pass() -> Result<(), JsValue> {
let url = "http://localhost:45678/tokenizer.json";

let json = load_json(&url).await?;

let json_str = js_sys::JSON::stringify(&json)?;

console::log_2(&"Logging arbitrary values looks like".into(), &json_str);
Expand Down

0 comments on commit 6e316ea

Please sign in to comment.