dioxus/packages/ssr/tests/bool_attr.rs

38 lines
773 B
Rust
Raw Normal View History

2023-08-08 17:56:41 +00:00
use dioxus::prelude::*;
#[test]
fn static_boolean_attributs() {
2024-01-15 17:12:24 +00:00
fn app() -> Element {
2023-08-08 17:56:41 +00:00
render! {
div { hidden: "false" }
div { hidden: "true" }
}
}
let mut dom = VirtualDom::new(app);
2024-01-10 23:57:15 +00:00
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
2023-08-08 17:56:41 +00:00
assert_eq!(
dioxus_ssr::render(&dom),
r#"<div></div><div hidden="true"></div>"#
);
}
#[test]
fn dynamic_boolean_attributs() {
2024-01-15 17:12:24 +00:00
fn app() -> Element {
2023-08-08 17:56:41 +00:00
render! {
div { hidden: false }
div { hidden: true }
}
}
let mut dom = VirtualDom::new(app);
2024-01-10 23:57:15 +00:00
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
2023-08-08 17:56:41 +00:00
assert_eq!(
dioxus_ssr::render(&dom),
r#"<div></div><div hidden=true></div>"#
);
}