progress_element.rs 827 B

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