xpath_result.rs 638 B

123456789101112131415161718192021222324252627
  1. use wasm_bindgen::prelude::*;
  2. use wasm_bindgen_test::*;
  3. use web_sys::XPathResult;
  4. #[wasm_bindgen(module = "/tests/wasm/element.js")]
  5. extern "C" {
  6. fn new_xpath_result() -> XPathResult;
  7. }
  8. #[wasm_bindgen_test]
  9. fn test_xpath_result() {
  10. let xpath_result = new_xpath_result();
  11. assert_eq!(
  12. xpath_result.result_type(),
  13. XPathResult::UNORDERED_NODE_ITERATOR_TYPE
  14. );
  15. assert_eq!(xpath_result.invalid_iterator_state(), false);
  16. assert_eq!(
  17. xpath_result
  18. .iterate_next()
  19. .unwrap()
  20. .unwrap()
  21. .text_content()
  22. .unwrap(),
  23. "tomato"
  24. );
  25. }