1 use wasm_bindgen::prelude::*;
2 use wasm_bindgen_test::*;
3 use web_sys::HtmlProgressElement;
4 
5 #[wasm_bindgen(module = "/tests/wasm/element.js")]
6 extern "C" {
new_progress() -> HtmlProgressElement7     fn new_progress() -> HtmlProgressElement;
8 }
9 
10 #[wasm_bindgen_test]
test_progress_element()11 fn test_progress_element() {
12     let progress = new_progress();
13     progress.set_max(150.5);
14     assert_eq!(
15         progress.max(),
16         150.5,
17         "Maximum progress value should be 150.5."
18     );
19 
20     progress.set_value(22.);
21     assert_eq!(progress.value(), 22., "Progress value should be 22 units.");
22     assert_eq!(
23         progress.position(),
24         (22. / 150.5),
25         "Progress position should be 22 divided by the max possible value."
26     );
27 
28     assert!(
29         progress.labels().length() == 0,
30         "Our simple progress bar shouldn't be associated with any labels."
31     );
32 }
33