param_element.rs 817 B

123456789101112131415161718192021222324252627282930313233343536
  1. use wasm_bindgen::prelude::*;
  2. use wasm_bindgen_test::*;
  3. use web_sys::HtmlParamElement;
  4. #[wasm_bindgen(module = "/tests/wasm/element.js")]
  5. extern "C" {
  6. fn new_param() -> HtmlParamElement;
  7. }
  8. #[wasm_bindgen_test]
  9. fn test_param_element() {
  10. let param = new_param();
  11. param.set_name("color");
  12. assert_eq!(param.name(), "color", "Name of param should be 'color'.");
  13. param.set_value("purple");
  14. assert_eq!(
  15. param.value(),
  16. "purple",
  17. "Value of param should be 'purple'."
  18. );
  19. param.set_value_type("ref");
  20. assert_eq!(
  21. param.value_type(),
  22. "ref",
  23. "Value type of param should be 'ref'."
  24. );
  25. param.set_type("text/plain");
  26. assert_eq!(
  27. param.type_(),
  28. "text/plain",
  29. "Value of param should be 'text/plain'."
  30. );
  31. }