Tyler Wilcock 05f3eec76d Fix web-sys history unit test (#592)
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.
2018-07-31 06:55:30 -07:00

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);
}