mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-19 11:40:51 +00:00
In an actual browser, the changing of the history using the binding worked a little too well, and caused the test to fail if you refreshed the page or manually used the back and forward buttons. The stateful stuff has been removed - the remaining two assertions should adequately test that the binding works, which is the point of these tests anyways.
20 lines
652 B
Rust
20 lines
652 B
Rust
use wasm_bindgen_test::*;
|
|
use wasm_bindgen::prelude::*;
|
|
use web_sys::{History, ScrollRestoration};
|
|
use js_sys::Object;
|
|
|
|
#[wasm_bindgen]
|
|
extern {
|
|
#[wasm_bindgen(js_name = history, js_namespace = window)]
|
|
static HISTORY: History;
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn history() {
|
|
HISTORY.set_scroll_restoration(ScrollRestoration::Manual).expect("failure to set scroll restoration");
|
|
assert_eq!(HISTORY.scroll_restoration().unwrap(), ScrollRestoration::Manual);
|
|
|
|
HISTORY.set_scroll_restoration(ScrollRestoration::Auto).expect("failure to set scroll restoration");
|
|
assert_eq!(HISTORY.scroll_restoration().unwrap(), ScrollRestoration::Auto);
|
|
}
|