diff_iterative.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //! tests to prove that the iterative implementation works
  2. use dioxus::prelude::*;
  3. mod test_logging;
  4. use dioxus_core as dioxus;
  5. use dioxus_html as dioxus_elements;
  6. const LOGGING_ENABLED: bool = false;
  7. #[async_std::test]
  8. async fn test_iterative_create_components() {
  9. static App: FC<()> = |cx| {
  10. // test root fragments
  11. cx.render(rsx! {
  12. Child { "abc1" }
  13. Child { "abc2" }
  14. Child { "abc3" }
  15. })
  16. };
  17. fn Child(cx: Context<()>) -> DomTree {
  18. // test root fragments, anchors, and ChildNode type
  19. cx.render(rsx! {
  20. h1 {}
  21. div { {cx.children()} }
  22. Fragment {
  23. Fragment {
  24. Fragment {
  25. "wozza"
  26. }
  27. }
  28. }
  29. {(0..0).map(|f| rsx!{ div { "walalla"}})}
  30. p {}
  31. })
  32. }
  33. test_logging::set_up_logging(LOGGING_ENABLED);
  34. let mut dom = VirtualDom::new(App);
  35. let mutations = dom.rebuild_async().await.unwrap();
  36. dbg!(mutations);
  37. let mutations = dom.diff_async().await.unwrap();
  38. dbg!(mutations);
  39. }