More tests around class and element naming

This commit is contained in:
Jeremy Wall 2022-10-07 10:21:26 -04:00
parent c311de79b1
commit ff6e9a5079

View File

@ -20,7 +20,7 @@ use web_sys::{window, Element, HtmlElement};
pub use wasm_web_component_macros::web_component; pub use wasm_web_component_macros::web_component;
/// Helper trait for Rust Web Components. This is autogenerated /// Helper trait for Rust Web Components. This is autogenerated
/// by the [`#[web_component]`](wasm_web_component_macros::web_component) attribute. /// by the [`#[web_component]`](web_component) attribute.
pub trait WebComponentDef: IntoWasmAbi + Default { pub trait WebComponentDef: IntoWasmAbi + Default {
fn new() -> Self { fn new() -> Self {
Self::default() Self::default()
@ -216,4 +216,14 @@ mod tests {
assert_eq!(AnotherElement::class_name(), "AnotherElement"); assert_eq!(AnotherElement::class_name(), "AnotherElement");
assert_eq!(AnotherElement::element_name(), "another-element"); assert_eq!(AnotherElement::element_name(), "another-element");
} }
#[wasm_bindgen_test]
fn test_component_no_class_name_with_element_name() {
#[web_component(element_name = "this-old-element")]
pub struct ThisElement {}
impl WebComponentBinding for ThisElement {}
assert_eq!(ThisElement::class_name(), "ThisElement");
assert_eq!(ThisElement::element_name(), "this-old-element");
}
} }