Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Oct 31, 2023
1 parent 97fc45f commit b8eeb06
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/tests/readable_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,17 @@ async fn test_readable_stream_into_stream_then_into_async_read() {
assert_eq!(async_read.read(&mut buf).await.unwrap(), 0);
assert_eq!(&buf, &[4, 5, 6]);
}

#[wasm_bindgen_test]
async fn test_readable_stream_from_js_array() {
let js_array =
js_sys::Array::from_iter([JsValue::from_str("Hello"), JsValue::from_str("world!")]);
let mut readable = ReadableStream::from(js_array.unchecked_into());
assert!(!readable.is_locked());

let mut reader = readable.get_reader();
assert_eq!(reader.read().await.unwrap(), Some(JsValue::from("Hello")));
assert_eq!(reader.read().await.unwrap(), Some(JsValue::from("world!")));
assert_eq!(reader.read().await.unwrap(), None);
reader.closed().await.unwrap();
}

0 comments on commit b8eeb06

Please sign in to comment.