🎨 Convierte el ciclo de renderizado en async
`prepare()` de `Component`, `render()` de `Region` y `Template`, y la implementación de `ComponentRender` pasan a ser funciones async. Se actualizan todos los componentes base, helpers, tests y ejemplos.
This commit is contained in:
parent
9acd8cc51a
commit
9354894b3a
48 changed files with 436 additions and 365 deletions
|
|
@ -11,6 +11,7 @@ struct TestComp {
|
|||
text: String,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Component for TestComp {
|
||||
fn new() -> Self {
|
||||
Self::default()
|
||||
|
|
@ -20,7 +21,7 @@ impl Component for TestComp {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
async fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
Ok(html! { (self.text) })
|
||||
}
|
||||
}
|
||||
|
|
@ -48,27 +49,30 @@ impl TestComp {
|
|||
async fn child_default_is_empty() {
|
||||
let child = Child::default();
|
||||
assert!(child.id().is_none());
|
||||
assert!(child.render(&mut Context::default()).is_empty());
|
||||
assert!(child.render(&mut Context::default()).await.is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn child_with_stores_component_and_renders_it() {
|
||||
let child = Child::with(TestComp::text("hola"));
|
||||
assert_eq!(child.render(&mut Context::default()).into_string(), "hola");
|
||||
let child = Child::with(TestComp::text("hello"));
|
||||
assert_eq!(
|
||||
child.render(&mut Context::default()).await.into_string(),
|
||||
"hello"
|
||||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn child_id_returns_component_id() {
|
||||
let child = Child::with(TestComp::tagged("my-id", "texto"));
|
||||
let child = Child::with(TestComp::tagged("my-id", "text"));
|
||||
assert_eq!(child.id(), Some("my-id".to_string()));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn child_from_component_is_equivalent_to_with() {
|
||||
let child: Child = TestComp::text("desde from").into();
|
||||
let child: Child = TestComp::text("from-trait").into();
|
||||
assert_eq!(
|
||||
child.render(&mut Context::default()).into_string(),
|
||||
"desde from"
|
||||
child.render(&mut Context::default()).await.into_string(),
|
||||
"from-trait"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -78,11 +82,11 @@ async fn child_clone_is_deep() {
|
|||
let original = Child::with(TestComp::text("original"));
|
||||
let clone = original.clone();
|
||||
assert_eq!(
|
||||
original.render(&mut Context::default()).into_string(),
|
||||
original.render(&mut Context::default()).await.into_string(),
|
||||
"original"
|
||||
);
|
||||
assert_eq!(
|
||||
clone.render(&mut Context::default()).into_string(),
|
||||
clone.render(&mut Context::default()).await.into_string(),
|
||||
"original"
|
||||
);
|
||||
}
|
||||
|
|
@ -103,7 +107,7 @@ async fn children_add_appends_in_order() {
|
|||
.with_child(TestComp::text("b"))
|
||||
.with_child(TestComp::text("c"));
|
||||
assert_eq!(c.len(), 3);
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "abc");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "abc");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -111,13 +115,13 @@ async fn children_add_if_empty_only_adds_when_list_is_empty() {
|
|||
let mut cx = Context::default();
|
||||
|
||||
// Se añade porque la lista está vacía.
|
||||
let c = Children::new().with_child(ChildOp::AddIfEmpty(TestComp::text("primero").into()));
|
||||
let c = Children::new().with_child(ChildOp::AddIfEmpty(TestComp::text("first").into()));
|
||||
assert_eq!(c.len(), 1);
|
||||
|
||||
// No se añade porque ya hay un elemento.
|
||||
let c = c.with_child(ChildOp::AddIfEmpty(TestComp::text("segundo").into()));
|
||||
let c = c.with_child(ChildOp::AddIfEmpty(TestComp::text("second").into()));
|
||||
assert_eq!(c.len(), 1);
|
||||
assert_eq!(c.render(&mut cx).into_string(), "primero");
|
||||
assert_eq!(c.render(&mut cx).await.into_string(), "first");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -128,7 +132,7 @@ async fn children_add_many_appends_all_in_order() {
|
|||
TestComp::text("z").into(),
|
||||
]));
|
||||
assert_eq!(c.len(), 3);
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "xyz");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "xyz");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -136,7 +140,7 @@ async fn children_prepend_inserts_at_start() {
|
|||
let c = Children::new()
|
||||
.with_child(TestComp::text("b"))
|
||||
.with_child(ChildOp::Prepend(TestComp::text("a").into()));
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "ab");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "ab");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -147,7 +151,7 @@ async fn children_prepend_many_inserts_all_at_start_maintaining_order() {
|
|||
TestComp::text("a").into(),
|
||||
TestComp::text("b").into(),
|
||||
]));
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "abc");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "abc");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -156,7 +160,7 @@ async fn children_insert_after_id_inserts_after_matching_element() {
|
|||
.with_child(TestComp::tagged("first", "a"))
|
||||
.with_child(TestComp::text("c"))
|
||||
.with_child(ChildOp::InsertAfterId("first", TestComp::text("b").into()));
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "abc");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "abc");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -164,10 +168,10 @@ async fn children_insert_after_id_appends_when_id_not_found() {
|
|||
let c = Children::new()
|
||||
.with_child(TestComp::text("a"))
|
||||
.with_child(ChildOp::InsertAfterId(
|
||||
"no-existe",
|
||||
"not-found",
|
||||
TestComp::text("b").into(),
|
||||
));
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "ab");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "ab");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -176,7 +180,7 @@ async fn children_insert_before_id_inserts_before_matching_element() {
|
|||
.with_child(TestComp::text("a"))
|
||||
.with_child(TestComp::tagged("last", "c"))
|
||||
.with_child(ChildOp::InsertBeforeId("last", TestComp::text("b").into()));
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "abc");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "abc");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -184,10 +188,10 @@ async fn children_insert_before_id_prepends_when_id_not_found() {
|
|||
let c = Children::new()
|
||||
.with_child(TestComp::text("b"))
|
||||
.with_child(ChildOp::InsertBeforeId(
|
||||
"no-existe",
|
||||
"not-found",
|
||||
TestComp::text("a").into(),
|
||||
));
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "ab");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "ab");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -198,28 +202,28 @@ async fn children_remove_by_id_removes_first_matching_element() {
|
|||
.with_child(TestComp::text("c"))
|
||||
.with_child(ChildOp::RemoveById("drop"));
|
||||
assert_eq!(c.len(), 2);
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "ac");
|
||||
assert_eq!(c.render(&mut Context::default()).await.into_string(), "ac");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn children_remove_by_id_does_nothing_when_id_not_found() {
|
||||
let c = Children::new()
|
||||
.with_child(TestComp::text("a"))
|
||||
.with_child(ChildOp::RemoveById("no-existe"));
|
||||
.with_child(ChildOp::RemoveById("not-found"));
|
||||
assert_eq!(c.len(), 1);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn children_replace_by_id_replaces_first_matching_element() {
|
||||
let c = Children::new()
|
||||
.with_child(TestComp::tagged("target", "viejo"))
|
||||
.with_child(TestComp::tagged("target", "old"))
|
||||
.with_child(TestComp::text("b"))
|
||||
.with_child(ChildOp::ReplaceById(
|
||||
"target",
|
||||
TestComp::text("nuevo").into(),
|
||||
));
|
||||
.with_child(ChildOp::ReplaceById("target", TestComp::text("new").into()));
|
||||
assert_eq!(c.len(), 2);
|
||||
assert_eq!(c.render(&mut Context::default()).into_string(), "nuevob");
|
||||
assert_eq!(
|
||||
c.render(&mut Context::default()).await.into_string(),
|
||||
"newb"
|
||||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -234,11 +238,11 @@ async fn children_reset_clears_all_elements() {
|
|||
#[pagetop::test]
|
||||
async fn children_get_by_id_returns_first_matching_child() {
|
||||
let c = Children::new()
|
||||
.with_child(TestComp::tagged("uno", "a"))
|
||||
.with_child(TestComp::tagged("dos", "b"));
|
||||
assert!(c.get_by_id("uno").is_some());
|
||||
assert!(c.get_by_id("dos").is_some());
|
||||
assert!(c.get_by_id("tres").is_none());
|
||||
.with_child(TestComp::tagged("one", "a"))
|
||||
.with_child(TestComp::tagged("two", "b"));
|
||||
assert!(c.get_by_id("one").is_some());
|
||||
assert!(c.get_by_id("two").is_some());
|
||||
assert!(c.get_by_id("three").is_none());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -246,21 +250,21 @@ async fn children_iter_by_id_yields_all_matching_children() {
|
|||
let c = Children::new()
|
||||
.with_child(TestComp::tagged("rep", "a"))
|
||||
.with_child(TestComp::tagged("rep", "b"))
|
||||
.with_child(TestComp::tagged("otro", "c"));
|
||||
.with_child(TestComp::tagged("other", "c"));
|
||||
assert_eq!(c.iter_by_id("rep").count(), 2);
|
||||
assert_eq!(c.iter_by_id("otro").count(), 1);
|
||||
assert_eq!(c.iter_by_id("ninguno").count(), 0);
|
||||
assert_eq!(c.iter_by_id("other").count(), 1);
|
||||
assert_eq!(c.iter_by_id("none").count(), 0);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn children_render_concatenates_all_outputs_in_order() {
|
||||
let c = Children::new()
|
||||
.with_child(TestComp::text("uno "))
|
||||
.with_child(TestComp::text("dos "))
|
||||
.with_child(TestComp::text("tres"));
|
||||
.with_child(TestComp::text("one "))
|
||||
.with_child(TestComp::text("two "))
|
||||
.with_child(TestComp::text("three"));
|
||||
assert_eq!(
|
||||
c.render(&mut Context::default()).into_string(),
|
||||
"uno dos tres"
|
||||
c.render(&mut Context::default()).await.into_string(),
|
||||
"one two three"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -270,29 +274,29 @@ async fn children_render_concatenates_all_outputs_in_order() {
|
|||
async fn embed_default_is_empty() {
|
||||
let embed: Embed<TestComp> = Embed::default();
|
||||
assert!(embed.id().is_none());
|
||||
assert!(embed.render(&mut Context::default()).is_empty());
|
||||
assert!(embed.render(&mut Context::default()).await.is_empty());
|
||||
assert!(embed.get().is_none());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn embed_with_stores_component() {
|
||||
let embed = Embed::with(TestComp::text("contenido"));
|
||||
let embed = Embed::with(TestComp::text("content"));
|
||||
assert!(embed.get().is_some());
|
||||
assert_eq!(
|
||||
embed.render(&mut Context::default()).into_string(),
|
||||
"contenido"
|
||||
embed.render(&mut Context::default()).await.into_string(),
|
||||
"content"
|
||||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn embed_id_returns_component_id() {
|
||||
let embed = Embed::with(TestComp::tagged("embed-id", "texto"));
|
||||
let embed = Embed::with(TestComp::tagged("embed-id", "text"));
|
||||
assert_eq!(embed.id(), Some("embed-id".to_string()));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn embed_get_is_some_when_component_present() {
|
||||
let embed = Embed::with(TestComp::tagged("abc", "hola"));
|
||||
let embed = Embed::with(TestComp::tagged("abc", "hello"));
|
||||
// `get()` devuelve Some; la lectura del id verifica que accede al componente correctamente.
|
||||
assert!(embed.get().is_some());
|
||||
assert_eq!(embed.id(), Some("abc".to_string()));
|
||||
|
|
@ -300,38 +304,36 @@ async fn embed_get_is_some_when_component_present() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn embed_get_allows_mutating_component() {
|
||||
let embed = Embed::with(TestComp::tagged("orig", "texto"));
|
||||
// El `;` final convierte el `if let` en sentencia y libera el guard antes que `embed`.
|
||||
if let Some(mut comp) = embed.get() {
|
||||
let mut embed = Embed::with(TestComp::tagged("orig", "text"));
|
||||
if let Some(comp) = embed.get_mut() {
|
||||
comp.props
|
||||
.alter_prop(PropsOp::set_id("modificado".to_string()));
|
||||
.alter_prop(PropsOp::set_id("modified".to_string()));
|
||||
};
|
||||
assert_eq!(embed.id(), Some("modificado".to_string()));
|
||||
assert_eq!(embed.id(), Some("modified".to_string()));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn embed_with_component_replaces_content() {
|
||||
let embed =
|
||||
Embed::with(TestComp::text("primero")).with_component(Some(TestComp::text("segundo")));
|
||||
let embed = Embed::with(TestComp::text("first")).with_component(Some(TestComp::text("second")));
|
||||
assert_eq!(
|
||||
embed.render(&mut Context::default()).into_string(),
|
||||
"segundo"
|
||||
embed.render(&mut Context::default()).await.into_string(),
|
||||
"second"
|
||||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn embed_with_component_none_empties_embed() {
|
||||
let embed = Embed::with(TestComp::text("algo")).with_component(None);
|
||||
let embed = Embed::with(TestComp::text("something")).with_component(None);
|
||||
assert!(embed.get().is_none());
|
||||
assert!(embed.render(&mut Context::default()).is_empty());
|
||||
assert!(embed.render(&mut Context::default()).await.is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn embed_clone_is_deep() {
|
||||
let original = Embed::with(TestComp::tagged("orig", "texto"));
|
||||
let clone = original.clone();
|
||||
let original = Embed::with(TestComp::tagged("orig", "text"));
|
||||
let mut clone = original.clone();
|
||||
// Mutar el clon no debe afectar al original.
|
||||
if let Some(mut comp) = clone.get() {
|
||||
if let Some(comp) = clone.get_mut() {
|
||||
comp.props
|
||||
.alter_prop(PropsOp::set_id("clone-id".to_string()));
|
||||
}
|
||||
|
|
@ -341,10 +343,10 @@ async fn embed_clone_is_deep() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn embed_converts_into_child() {
|
||||
let embed = Embed::with(TestComp::text("desde embed"));
|
||||
let embed = Embed::with(TestComp::text("from embed"));
|
||||
let child = Child::from(embed);
|
||||
assert_eq!(
|
||||
child.render(&mut Context::default()).into_string(),
|
||||
"desde embed"
|
||||
child.render(&mut Context::default()).await.into_string(),
|
||||
"from embed"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ async fn component_html_renders_static_markup() {
|
|||
}
|
||||
});
|
||||
|
||||
let markup = component.render(&mut Context::default());
|
||||
assert_eq!(markup.0, "<p>Test</p>");
|
||||
let markup = component.render(&mut Context::default()).await;
|
||||
assert_eq!(markup.into_string(), "<p>Test</p>");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -23,8 +23,8 @@ async fn component_html_renders_using_context_param() {
|
|||
}
|
||||
});
|
||||
|
||||
let markup = component.render(&mut cx);
|
||||
assert_eq!(markup.0, "<span>Alice</span>");
|
||||
let markup = component.render(&mut cx).await;
|
||||
assert_eq!(markup.into_string(), "<span>Alice</span>");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -33,16 +33,16 @@ async fn component_html_allows_replacing_render_function() {
|
|||
|
||||
component.alter_fn(|_| html! { div { "Modified" } });
|
||||
|
||||
let markup = component.render(&mut Context::default());
|
||||
assert_eq!(markup.0, "<div>Modified</div>");
|
||||
let markup = component.render(&mut Context::default()).await;
|
||||
assert_eq!(markup.into_string(), "<div>Modified</div>");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn component_html_default_renders_empty_markup() {
|
||||
let mut component = Html::default();
|
||||
|
||||
let markup = component.render(&mut Context::default());
|
||||
assert_eq!(markup.0, "");
|
||||
let markup = component.render(&mut Context::default()).await;
|
||||
assert_eq!(markup.into_string(), "");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -60,6 +60,6 @@ async fn component_html_can_access_request_path() {
|
|||
html! { span { (path) } }
|
||||
});
|
||||
|
||||
let markup = component.render(&mut cx);
|
||||
assert_eq!(markup.0, "<span>/hello/world</span>");
|
||||
let markup = component.render(&mut cx).await;
|
||||
assert_eq!(markup.into_string(), "<span>/hello/world</span>");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ async fn poweredby_default_shows_only_pagetop_recognition() {
|
|||
setup().await;
|
||||
|
||||
let mut p = PoweredBy::default();
|
||||
let html = p.render(&mut Context::default());
|
||||
let html = p.render(&mut Context::default()).await.into_string();
|
||||
|
||||
// Debe mostrar el bloque de reconocimiento a PageTop.
|
||||
assert!(html.as_str().contains("poweredby__pagetop"));
|
||||
assert!(html.contains("poweredby__pagetop"));
|
||||
|
||||
// Y NO debe mostrar el bloque de copyright.
|
||||
assert!(!html.as_str().contains("poweredby__copyright"));
|
||||
assert!(!html.contains("poweredby__copyright"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -27,23 +27,20 @@ async fn poweredby_new_includes_current_year_and_app_name() {
|
|||
setup().await;
|
||||
|
||||
let mut p = PoweredBy::new();
|
||||
let html = p.render(&mut Context::default());
|
||||
let html = p.render(&mut Context::default()).await.into_string();
|
||||
|
||||
let year = Utc::now().format("%Y").to_string();
|
||||
assert!(
|
||||
html.as_str().contains(&year),
|
||||
"HTML should include the current year"
|
||||
);
|
||||
assert!(html.contains(&year), "HTML should include the current year");
|
||||
|
||||
// El nombre de la app proviene de `global::SETTINGS.app.name`.
|
||||
let app_name = &global::SETTINGS.app.name;
|
||||
assert!(
|
||||
html.as_str().contains(app_name),
|
||||
html.contains(app_name),
|
||||
"HTML should include the application name"
|
||||
);
|
||||
|
||||
// Debe existir el span de copyright.
|
||||
assert!(html.as_str().contains("poweredby__copyright"));
|
||||
assert!(html.contains("poweredby__copyright"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -52,10 +49,10 @@ async fn poweredby_with_copyright_overrides_text() {
|
|||
|
||||
let custom = "2001 © FooBar Inc.";
|
||||
let mut p = PoweredBy::default().with_copyright(Some(custom));
|
||||
let html = p.render(&mut Context::default());
|
||||
let html = p.render(&mut Context::default()).await.into_string();
|
||||
|
||||
assert!(html.as_str().contains(custom));
|
||||
assert!(html.as_str().contains("poweredby__copyright"));
|
||||
assert!(html.contains(custom));
|
||||
assert!(html.contains("poweredby__copyright"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -63,11 +60,11 @@ async fn poweredby_with_copyright_none_hides_text() {
|
|||
setup().await;
|
||||
|
||||
let mut p = PoweredBy::new().with_copyright(None::<String>);
|
||||
let html = p.render(&mut Context::default());
|
||||
let html = p.render(&mut Context::default()).await.into_string();
|
||||
|
||||
assert!(!html.as_str().contains("poweredby__copyright"));
|
||||
assert!(!html.contains("poweredby__copyright"));
|
||||
// El reconocimiento a PageTop siempre debe aparecer.
|
||||
assert!(html.as_str().contains("poweredby__pagetop"));
|
||||
assert!(html.contains("poweredby__pagetop"));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -75,10 +72,10 @@ async fn poweredby_link_points_to_crates_io() {
|
|||
setup().await;
|
||||
|
||||
let mut p = PoweredBy::default();
|
||||
let html = p.render(&mut Context::default());
|
||||
let html = p.render(&mut Context::default()).await.into_string();
|
||||
|
||||
assert!(
|
||||
html.as_str().contains("https://pagetop.cillero.es"),
|
||||
html.contains("https://pagetop.cillero.es"),
|
||||
"Link should point to pagetop.cillero.es"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ struct TestMarkupComponent {
|
|||
markup: Markup,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Component for TestMarkupComponent {
|
||||
fn new() -> Self {
|
||||
Self::default()
|
||||
|
|
@ -17,7 +18,7 @@ impl Component for TestMarkupComponent {
|
|||
cx.param_or::<bool>("renderable", true)
|
||||
}
|
||||
|
||||
fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
async fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
Ok(self.markup.clone())
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +75,7 @@ async fn non_renderable_component_produces_empty_markup() {
|
|||
let mut comp = TestMarkupComponent {
|
||||
markup: html! { p { "Should never be rendered" } },
|
||||
};
|
||||
assert_eq!(comp.render(&mut cx).into_string(), "");
|
||||
assert_eq!(comp.render(&mut cx).await.into_string(), "");
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -93,7 +94,7 @@ async fn markup_from_component_equals_markup_reinjected_in_html_macro() {
|
|||
let mut comp = TestMarkupComponent {
|
||||
markup: markup.clone(),
|
||||
};
|
||||
comp.render(&mut cx).into_string()
|
||||
comp.render(&mut cx).await.into_string()
|
||||
};
|
||||
|
||||
// Vía 2: reinyectamos el Markup en `html!` directamente.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue