dioxus/packages/ssr/tests/styles.rs

41 lines
818 B
Rust
Raw Normal View History

2023-03-22 15:10:18 +00:00
use dioxus::prelude::*;
#[test]
fn static_styles() {
2024-01-15 17:12:24 +00:00
fn app() -> Element {
2023-03-22 15:10:18 +00:00
render! { div { width: "100px" } }
}
let mut dom = VirtualDom::new(app);
2024-01-10 23:57:15 +00:00
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
2023-03-22 15:10:18 +00:00
assert_eq!(
dioxus_ssr::render(&dom),
r#"<div style="width:100px;"></div>"#
);
}
#[test]
fn partially_dynamic_styles() {
let dynamic = 123;
assert_eq!(
2024-01-10 23:57:15 +00:00
dioxus_ssr::render_element(render! {
2023-03-22 15:10:18 +00:00
div { width: "100px", height: "{dynamic}px" }
}),
r#"<div style="width:100px;height:123px;"></div>"#
);
}
#[test]
fn dynamic_styles() {
let dynamic = 123;
assert_eq!(
2024-01-10 23:57:15 +00:00
dioxus_ssr::render_element(render! {
2023-03-22 15:10:18 +00:00
div { width: "{dynamic}px" }
}),
r#"<div style="width:123px;"></div>"#
);
}