1 use wasm_bindgen::prelude::*;
2 use wasm_bindgen_test::*;
3 use web_sys::HtmlMeterElement;
4 
5 #[wasm_bindgen(module = "/tests/wasm/element.js")]
6 extern "C" {
new_meter() -> HtmlMeterElement7     fn new_meter() -> HtmlMeterElement;
8 }
9 
10 #[wasm_bindgen_test]
test_meter_element()11 fn test_meter_element() {
12     let meter = new_meter();
13 
14     meter.set_min(-5.);
15     assert_eq!(
16         meter.min(),
17         -5.,
18         "Meter should have the min value we gave it."
19     );
20 
21     meter.set_max(5.);
22     assert_eq!(
23         meter.max(),
24         5.,
25         "Meter should have the max value we gave it."
26     );
27 
28     meter.set_value(2.);
29     assert_eq!(meter.value(), 2., "Meter should have the value we gave it.");
30 
31     meter.set_low(-1.);
32     assert_eq!(
33         meter.low(),
34         -1.,
35         "Meter should have the low value we gave it."
36     );
37 
38     meter.set_high(1.);
39     assert_eq!(
40         meter.high(),
41         1.,
42         "Meter should have the high value we gave it."
43     );
44 
45     meter.set_optimum(3.);
46     assert_eq!(
47         meter.optimum(),
48         3.,
49         "Meter should have the optimum value we gave it."
50     );
51 
52     assert!(
53         meter.labels().length() == 0,
54         "Our meter shouldn't have any labels associated with it."
55     );
56 }
57