refactor(techdemo): render test metric with hemplate
Replace the techdemo generated-slot test's inline raw HTML payload with a hemplate partial-rendered view. req: html_safety/002 req: view/001
This commit is contained in:
@@ -4,15 +4,22 @@ pub mod ui {}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ui;
|
||||
use hemplate::Hemplate;
|
||||
use slhx::{IntoEffect, SafeHtml};
|
||||
use slhx_test::inspect;
|
||||
|
||||
#[derive(Hemplate)]
|
||||
#[hemplate = "partials"]
|
||||
struct FastMetric {
|
||||
label: &'static str,
|
||||
}
|
||||
|
||||
// req: examples/001 req: codegen/002 req: public_api/001
|
||||
#[test]
|
||||
fn techdemo_uses_generated_slots_for_multi_target_updates() {
|
||||
fn update() -> impl IntoEffect {
|
||||
(
|
||||
ui::control_center::slots::hero_metrics.html(SafeHtml::trusted("<b>fast</b>")),
|
||||
ui::control_center::slots::hero_metrics.html(render_fast_metric("fast")),
|
||||
ui::control_center::slots::notice.text("typed"),
|
||||
)
|
||||
}
|
||||
@@ -22,6 +29,15 @@ mod tests {
|
||||
assert!(batch.has_slot(ui::control_center::slots::notice));
|
||||
}
|
||||
|
||||
fn render_fast_metric(label: &'static str) -> SafeHtml {
|
||||
// req: html_safety/002 req: view/001
|
||||
SafeHtml::trusted(
|
||||
FastMetric { label }
|
||||
.render()
|
||||
.expect("techdemo fast metric renders"),
|
||||
)
|
||||
}
|
||||
|
||||
// req: examples/001 req: form/002 req: codegen/003
|
||||
#[test]
|
||||
fn techdemo_exports_form_and_interaction_handles() {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<b>{+ self.label +}</b>
|
||||
Reference in New Issue
Block a user