1 use wasm_bindgen_test::*;
2 use wasm_bindgen::prelude::*;
3 use web_sys::HtmlMenuItemElement;
4 
5 #[wasm_bindgen(module = "/tests/wasm/element.js")]
6 extern "C" {
new_menuitem() -> HtmlMenuItemElement7     fn new_menuitem() -> HtmlMenuItemElement;
8 }
9 
10 #[wasm_bindgen_test]
test_menuitem_element()11 fn test_menuitem_element() {
12     let menuitem = new_menuitem();
13 
14     menuitem.set_type("radio");
15     assert_eq!(menuitem.type_(), "radio", "Menu item should have the type value we gave it.");
16 
17     menuitem.set_label("Menu item label here");
18     assert_eq!(menuitem.label(), "Menu item label here", "Menu item should have the label value we gave it.");
19 
20     menuitem.set_icon("https://en.wikipedia.org/wiki/Rust_(programming_language)#/media/File:Rust_programming_language_black_logo.svg");
21     assert_eq!(menuitem.icon(), "https://en.wikipedia.org/wiki/Rust_(programming_language)#/media/File:Rust_programming_language_black_logo.svg", "Menu item should have the icon value we gave it.");
22 
23     menuitem.set_disabled(true);
24     assert_eq!(menuitem.disabled(), true, "Menu item should be disabled after we set it to be disabled.");
25 
26     menuitem.set_disabled(false);
27     assert_eq!(menuitem.disabled(), false, "Menu item should not be disabled after we set it to be not-disabled.");
28 
29     menuitem.set_checked(true);
30     assert_eq!(menuitem.checked(), true, "Menu item should be checked after we set it to be checked.");
31 
32     menuitem.set_checked(false);
33     assert_eq!(menuitem.checked(), false, "Menu item should not be checked after we set it to be not-checked.");
34 
35     menuitem.set_radiogroup("Radio group name");
36     assert_eq!(menuitem.radiogroup(), "Radio group name", "Menu item should have the radiogroup value we gave it.");
37 
38     menuitem.set_default_checked(true);
39     assert_eq!(menuitem.default_checked(), true, "Menu item should be default_checked after we set it to be default_checked.");
40 
41     menuitem.set_default_checked(false);
42     assert_eq!(menuitem.default_checked(), false, "Menu item should not be default_checked after we set it to be not default_checked.");
43 }
44