diff --git a/playground/dx-test/Cargo.toml b/playground/dx-test/Cargo.toml index 656b655..9668172 100644 --- a/playground/dx-test/Cargo.toml +++ b/playground/dx-test/Cargo.toml @@ -12,3 +12,6 @@ dioxus = { version = "0.5", features = ["desktop", "router"] } # Debug dioxus-logger = "0.5.1" +dioxus-ssr = "0.5.6" +futures = "0.3.30" +pretty_assertions = "1.4.1" diff --git a/playground/dx-test/tests/hello_test.rs b/playground/dx-test/tests/hello_test.rs new file mode 100644 index 0000000..3f5a5ff --- /dev/null +++ b/playground/dx-test/tests/hello_test.rs @@ -0,0 +1,25 @@ +use futures::FutureExt; +use std::{cell::RefCell, sync::Arc}; + +use dioxus::prelude::*; + +#[test] +fn test() { + assert_rsx_eq( + rsx! { + div { "Hello world" } + div { "Hello world" } + }, + rsx! { + for _ in 0..2 { + div { "Hello world" } + } + }, + ) +} + +fn assert_rsx_eq(first: Element, second: Element) { + let first = dioxus_ssr::render_element(first); + let second = dioxus_ssr::render_element(second); + pretty_assertions::assert_str_eq!(first, second); +} \ No newline at end of file diff --git a/playground/justfile b/playground/justfile index c857a1a..a8f253e 100644 --- a/playground/justfile +++ b/playground/justfile @@ -8,4 +8,8 @@ dx-new: dx-css: cd {{invocation_directory()}}; bunx tailwindcss -i ./input.css -o ./assets/tailwind.css --watch dx-dev: - cd {{invocation_directory()}}; dx serve --hot-reload --platform desktop \ No newline at end of file + cd {{invocation_directory()}}; dx serve --hot-reload --platform desktop +dx-test: dx-prep-test + cd {{invocation_directory()}}; cargo test +dx-prep-test: + cd {{invocation_directory()}}; cargo add dioxus-ssr pretty_assertions futures \ No newline at end of file