Skip to content

Commit

Permalink
Add tests for dx
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Oct 2, 2024
1 parent b25e751 commit 27d08d7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions playground/dx-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
25 changes: 25 additions & 0 deletions playground/dx-test/tests/hello_test.rs
Original file line number Diff line number Diff line change
@@ -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);
}
6 changes: 5 additions & 1 deletion playground/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit 27d08d7

Please sign in to comment.