use sauron::html::*; use sauron::*; use test_fixtures::simple_program; use wasm_bindgen_test::*; mod test_fixtures; wasm_bindgen_test_configure!(run_in_browser); /// this is an inefficient patch since the blank lines are matches /// causing the next good match to skip due to the there has been /// a previous match with bigger node_idx /// The solution is therefore to not put key to elements that /// are meant to be discarded and can easily be construcated #[wasm_bindgen_test] fn test1() { console_log::init_with_level(log::Level::Trace).ok(); console_error_panic_hook::set_once(); let current_dom: Node<()> = node!(

"Lines"

"0"
"C"
"J"
"K"
"\n"
"1"
"\n"
"2"
"T"
"h"
"e"
"\n"
"line: 0, column: 0"
); let target_dom: Node<()> = node!(

"Lines"

"0"
"\n"
"1"
"C"
"J"
"K"
"\n"
"2"
"\n"
"3"
"T"
"h"
"e"
"\n"
"line: 1, column: 0"
); let patch = diff(¤t_dom, &target_dom); log::trace!("test update here.."); log::debug!("patches: {:#?}", patch); dbg!(&patch); let mut simple_program = simple_program(); simple_program .update_dom_with_vdom(current_dom.clone()) .expect("must not error"); let target_dom_html = target_dom.render_to_string(); simple_program .update_dom_with_vdom(target_dom) .expect("must not error"); let app_node = crate::document() .query_selector(".app") .expect("must not error") .expect("must exist"); assert_eq!(target_dom_html, app_node.outer_html()); }