2018-08-02 02:11:29 +03:00
|
|
|
use wasm_bindgen::prelude::*;
|
2018-09-26 18:26:00 +03:00
|
|
|
use wasm_bindgen_test::*;
|
2018-08-02 02:11:29 +03:00
|
|
|
use web_sys::HtmlProgressElement;
|
|
|
|
|
|
|
|
#[wasm_bindgen(module = "./tests/wasm/element.js")]
|
2018-09-26 18:26:00 +03:00
|
|
|
extern "C" {
|
2018-08-02 02:11:29 +03:00
|
|
|
fn new_progress() -> HtmlProgressElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn test_progress_element() {
|
|
|
|
let progress = new_progress();
|
|
|
|
progress.set_max(150.5);
|
2018-09-26 18:26:00 +03:00
|
|
|
assert_eq!(
|
|
|
|
progress.max(),
|
|
|
|
150.5,
|
|
|
|
"Maximum progress value should be 150.5."
|
|
|
|
);
|
2018-08-02 02:11:29 +03:00
|
|
|
|
|
|
|
progress.set_value(22.);
|
|
|
|
assert_eq!(progress.value(), 22., "Progress value should be 22 units.");
|
2018-09-26 18:26:00 +03:00
|
|
|
assert_eq!(
|
|
|
|
progress.position(),
|
|
|
|
(22. / 150.5),
|
|
|
|
"Progress position should be 22 divided by the max possible value."
|
|
|
|
);
|
2018-08-02 02:11:29 +03:00
|
|
|
|
2018-09-26 18:26:00 +03:00
|
|
|
assert!(
|
|
|
|
progress.labels().length() == 0,
|
|
|
|
"Our simple progress bar shouldn't be associated with any labels."
|
|
|
|
);
|
|
|
|
}
|