mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-30 19:41:56 +00:00
Add unit tests for even more 'web-sys' bindings
That list includes: * HtmlMenuElement * HtmlMenuItemElement * HtmlMetaElement * HtmlMeterElement
This commit is contained in:
committed by
Alex Crichton
parent
07b4ef5838
commit
0624b0cf2e
33
crates/web-sys/tests/wasm/meter_element.rs
Normal file
33
crates/web-sys/tests/wasm/meter_element.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::HtmlMeterElement;
|
||||
|
||||
#[wasm_bindgen(module = "./tests/wasm/element.js")]
|
||||
extern {
|
||||
fn new_meter() -> HtmlMeterElement;
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_meter_element() {
|
||||
let meter = new_meter();
|
||||
|
||||
meter.set_min(-5.);
|
||||
assert_eq!(meter.min(), -5., "Meter should have the min value we gave it.");
|
||||
|
||||
meter.set_max(5.);
|
||||
assert_eq!(meter.max(), 5., "Meter should have the max value we gave it.");
|
||||
|
||||
meter.set_value(2.);
|
||||
assert_eq!(meter.value(), 2., "Meter should have the value we gave it.");
|
||||
|
||||
meter.set_low(-1.);
|
||||
assert_eq!(meter.low(), -1., "Meter should have the low value we gave it.");
|
||||
|
||||
meter.set_high(1.);
|
||||
assert_eq!(meter.high(), 1., "Meter should have the high value we gave it.");
|
||||
|
||||
meter.set_optimum(3.);
|
||||
assert_eq!(meter.optimum(), 3., "Meter should have the optimum value we gave it.");
|
||||
|
||||
assert!(meter.labels().length() == 0, "Our meter shouldn't have any labels associated with it.");
|
||||
}
|
Reference in New Issue
Block a user