use dioxus::prelude::*; #[test] fn simple() { fn app(cx: Scope) -> Element { render! { div { "hello!" } } } let mut dom = VirtualDom::new(app); _ = dom.rebuild(); assert_eq!(dioxus_ssr::render(&dom), "
hello!
"); assert_eq!( dioxus_ssr::render_lazy(rsx!( div {"hello!"} )), "
hello!
" ); } #[test] fn lists() { assert_eq!( dioxus_ssr::render_lazy(rsx! { ul { (0..5).map(|i| rsx! { li { "item {i}" } }) } }), "" ); } #[test] fn dynamic() { let dynamic = 123; assert_eq!( dioxus_ssr::render_lazy(rsx! { div { "Hello world 1 -->" "{dynamic}" "<-- Hello world 2" } }), "
Hello world 1 -->123<-- Hello world 2
" ); } #[test] fn components() { #[inline_props] fn my_component(cx: Scope, name: i32) -> Element { render! { div { "component {name}" } } } assert_eq!( dioxus_ssr::render_lazy(rsx! { div { (0..5).map(|name| rsx! { my_component { name: name } }) } }), "
component 0
component 1
component 2
component 3
component 4
" ); } #[test] fn fragments() { assert_eq!( dioxus_ssr::render_lazy(rsx! { div { (0..5).map(|_| rsx! (())) } }), "
" ); }