1 use wasm_bindgen_test::*; 2 use wasm_bindgen::prelude::*; 3 use web_sys::HtmlMenuElement; 4 5 #[wasm_bindgen(module = "/tests/wasm/element.js")] 6 extern "C" { new_menu() -> HtmlMenuElement7 fn new_menu() -> HtmlMenuElement; 8 } 9 10 #[wasm_bindgen_test] test_menu_element()11fn test_menu_element() { 12 let menu = new_menu(); 13 14 menu.set_type("toolbar"); 15 assert_eq!(menu.type_(), "toolbar", "Menu should have the type value we gave it."); 16 17 menu.set_label("Menu label here"); 18 assert_eq!(menu.label(), "Menu label here", "Menu should have the label value we gave it."); 19 20 menu.set_compact(true); 21 assert_eq!(menu.compact(), true, "Menu should be compact after we set it to be compact."); 22 23 menu.set_compact(false); 24 assert_eq!(menu.compact(), false, "Menu should not be compact after we set it to be not-compact."); 25 } 26