dioxus/packages/ssr/tests/bool_attr.rs

38 lines
761 B
Rust
Raw Normal View History

2023-08-08 17:56:41 +00:00
use dioxus::prelude::*;
#[test]
fn static_boolean_attributes() {
2024-01-15 17:12:24 +00:00
fn app() -> Element {
2024-01-16 19:18:46 +00:00
rsx! {
2023-08-08 17:56:41 +00:00
div { hidden: "false" }
div { hidden: "true" }
}
}
let mut dom = VirtualDom::new(app);
2024-02-05 07:03:52 +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_attributes() {
2024-01-15 17:12:24 +00:00
fn app() -> Element {
2024-01-16 19:18:46 +00:00
rsx! {
2023-08-08 17:56:41 +00:00
div { hidden: false }
div { hidden: true }
}
}
let mut dom = VirtualDom::new(app);
2024-02-05 07:03:52 +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>"#
);
}