chore: fix tests passing

This commit is contained in:
Jonathan Kelley 2022-12-07 15:29:32 -08:00
parent 0bf4725639
commit 7ce07e3164
2 changed files with 23 additions and 19 deletions

View file

@ -1,6 +1,7 @@
use dioxus_core::prelude::*; use dioxus_core::prelude::*;
use std::fmt::Write; use std::fmt::Write;
#[derive(Debug)]
pub struct StringCache { pub struct StringCache {
pub segments: Vec<Segment>, pub segments: Vec<Segment>,
pub template: Template<'static>, pub template: Template<'static>,

View file

@ -156,26 +156,29 @@ fn to_string_works() {
_ = dom.rebuild(); _ = dom.rebuild();
let mut renderer = Renderer::new(); let mut renderer = Renderer::new();
let out = renderer.render(&dom); let out = renderer.render(&dom);
use Segment::*; for item in renderer.template_cache.iter() {
assert_eq!( if item.1.segments.len() > 5 {
renderer.template_cache.iter().next().unwrap().1.segments, assert_eq!(
vec![ item.1.segments,
PreRendered("<div class=\"asdasdasd\" class=\"asdasdasd\"".into(),), vec![
Attr(0,), PreRendered("<div class=\"asdasdasd\" class=\"asdasdasd\"".into(),),
PreRendered(">Hello world 1 -->".into(),), Attr(0,),
Node(0,), PreRendered(">Hello world 1 -->".into(),),
PreRendered("<-- Hello world 2<div>nest 1</div><div></div><div>nest 2</div>".into(),), Node(0,),
Node(1,), PreRendered(
Node(2,), "<-- Hello world 2<div>nest 1</div><div></div><div>nest 2</div>".into(),
PreRendered("</div>".into(),), ),
] Node(1,),
); Node(2,),
PreRendered("</div>".into(),),
]
);
}
}
assert_eq!( use Segment::*;
out,
"<div class=\"asdasdasd\" class=\"asdasdasd\" id=\"id-123\">Hello world 1 --><!--#-->123<!--/#--><-- Hello world 2<div>nest 1</div><div></div><div>nest 2</div><!--#--></diiiiiiiiv><!--/#--><div><!--#-->finalize 0<!--/#--></div><div><!--#-->finalize 1<!--/#--></div><div><!--#-->finalize 2<!--/#--></div><div><!--#-->finalize 3<!--/#--></div><div><!--#-->finalize 4<!--/#--></div></div>" assert_eq!(out, "<div class=\"asdasdasd\" class=\"asdasdasd\" id=\"id-123\">Hello world 1 -->123<-- Hello world 2<div>nest 1</div><div></div><div>nest 2</div></diiiiiiiiv><div>finalize 0</div><div>finalize 1</div><div>finalize 2</div><div>finalize 3</div><div>finalize 4</div></div>");
);
} }