without_index.rs 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. use dioxus::prelude::*;
  2. // Tests for regressions of <https://github.com/DioxusLabs/dioxus/issues/2468>
  3. #[test]
  4. fn router_without_index_route_parses() {
  5. let mut vdom = VirtualDom::new_with_props(
  6. App,
  7. AppProps {
  8. path: Route::Test {},
  9. },
  10. );
  11. vdom.rebuild_in_place();
  12. let as_string = dioxus_ssr::render(&vdom);
  13. assert_eq!(as_string, "<div>router with no index route renders</div>")
  14. }
  15. #[derive(Routable, Clone, Copy, PartialEq, Debug)]
  16. enum Route {
  17. #[route("/test")]
  18. Test {},
  19. }
  20. #[component]
  21. fn Test() -> Element {
  22. rsx! {
  23. div {
  24. "router with no index route renders"
  25. }
  26. }
  27. }
  28. #[component]
  29. fn App(path: Route) -> Element {
  30. rsx! {
  31. Router::<Route> {
  32. config: {
  33. move || RouterConfig::default().history(MemoryHistory::with_initial_path(path))
  34. }
  35. }
  36. }
  37. }