2021-08-19 06:50:35 +00:00
|
|
|
//! tests to prove that the iterative implementation works
|
|
|
|
|
|
|
|
use anyhow::{Context, Result};
|
|
|
|
use dioxus::{
|
|
|
|
arena::SharedResources,
|
|
|
|
diff::{CreateMeta, DiffMachine},
|
|
|
|
prelude::*,
|
|
|
|
scheduler::Mutations,
|
|
|
|
DomEdit,
|
|
|
|
};
|
2021-08-21 17:24:47 +00:00
|
|
|
mod test_logging;
|
2021-08-19 06:50:35 +00:00
|
|
|
use dioxus_core as dioxus;
|
|
|
|
use dioxus_html as dioxus_elements;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_original_diff() {
|
|
|
|
static App: FC<()> = |cx| {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
div {
|
|
|
|
"Hello, world!"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut dom = VirtualDom::new(App);
|
|
|
|
let mutations = dom.rebuild().unwrap();
|
|
|
|
dbg!(mutations);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
2021-08-21 17:24:47 +00:00
|
|
|
async fn test_iterative_create() {
|
2021-08-19 06:50:35 +00:00
|
|
|
static App: FC<()> = |cx| {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
div {
|
|
|
|
"Hello, world!"
|
2021-08-21 17:24:47 +00:00
|
|
|
div {
|
|
|
|
div {
|
|
|
|
Fragment {
|
|
|
|
"hello"
|
|
|
|
"world"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-19 06:50:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
2021-08-21 17:24:47 +00:00
|
|
|
test_logging::set_up_logging();
|
2021-08-19 06:50:35 +00:00
|
|
|
|
2021-08-21 17:24:47 +00:00
|
|
|
let mut dom = VirtualDom::new(App);
|
|
|
|
let mutations = dom.rebuild_async().await.unwrap();
|
|
|
|
dbg!(mutations);
|
2021-08-19 06:50:35 +00:00
|
|
|
}
|
2021-08-20 15:39:13 +00:00
|
|
|
|
|
|
|
#[async_std::test]
|
2021-08-21 17:24:47 +00:00
|
|
|
async fn test_iterative_create_list() {
|
|
|
|
static App: FC<()> = |cx| {
|
|
|
|
cx.render(rsx! {
|
2021-08-22 03:04:34 +00:00
|
|
|
{(0..3).map(|f| rsx!{ div {
|
2021-08-21 17:24:47 +00:00
|
|
|
"hello"
|
|
|
|
}})}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
test_logging::set_up_logging();
|
|
|
|
|
|
|
|
let mut dom = VirtualDom::new(App);
|
|
|
|
let mutations = dom.rebuild_async().await.unwrap();
|
|
|
|
dbg!(mutations);
|
2021-08-20 15:39:13 +00:00
|
|
|
}
|
2021-08-21 17:24:47 +00:00
|
|
|
|
2021-08-22 03:04:34 +00:00
|
|
|
#[async_std::test]
|
|
|
|
async fn test_iterative_create_simple() {
|
|
|
|
static App: FC<()> = |cx| {
|
|
|
|
cx.render(rsx! {
|
|
|
|
div {}
|
|
|
|
div {}
|
|
|
|
div {}
|
|
|
|
div {}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
test_logging::set_up_logging();
|
|
|
|
|
|
|
|
let mut dom = VirtualDom::new(App);
|
|
|
|
let mutations = dom.rebuild_async().await.unwrap();
|
|
|
|
dbg!(mutations);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_iterative_create_components() {
|
|
|
|
static App: FC<()> = |cx| {
|
|
|
|
cx.render(rsx! {
|
|
|
|
Child { "abc1" }
|
|
|
|
Child { "abc2" }
|
|
|
|
Child { "abc3" }
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
static Child: FC<()> = |cx| {
|
|
|
|
cx.render(rsx! {
|
|
|
|
h1 {}
|
2021-08-22 21:08:25 +00:00
|
|
|
div { {cx.children()} }
|
2021-08-22 03:04:34 +00:00
|
|
|
p {}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
test_logging::set_up_logging();
|
|
|
|
|
|
|
|
let mut dom = VirtualDom::new(App);
|
|
|
|
let mutations = dom.rebuild_async().await.unwrap();
|
|
|
|
dbg!(mutations);
|
|
|
|
}
|