test(v0): render page swap content from hemplate
Exercise the v0 page-swap effect with a renderable hemplate view payload instead of an ad hoc HTML-looking text literal. req: view/001 req: html_safety/002 req: page_swap/002 req: page_swap/003
This commit is contained in:
+18
-2
@@ -36,6 +36,12 @@ mod tests {
|
|||||||
title: String,
|
title: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Hemplate)]
|
||||||
|
#[hemplate = "partials"]
|
||||||
|
struct DocsContent {
|
||||||
|
message: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
// req: examples/001 req: ceremony/001 req: build/001 req: build/005 req: codegen/002
|
// req: examples/001 req: ceremony/001 req: build/001 req: build/005 req: codegen/002
|
||||||
#[test]
|
#[test]
|
||||||
fn counter_updates_a_generated_slot() {
|
fn counter_updates_a_generated_slot() {
|
||||||
@@ -85,12 +91,12 @@ mod tests {
|
|||||||
assert!(matches!(effect.ops(), [Effect::Put { .. }]));
|
assert!(matches!(effect.ops(), [Effect::Put { .. }]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// req: examples/001 req: page_swap/002 req: page_swap/003 req: build/001 req: build/005
|
// req: examples/001 req: page_swap/002 req: page_swap/003 req: build/001 req: build/005 req: view/001
|
||||||
#[test]
|
#[test]
|
||||||
fn page_swap_updates_content_and_history() {
|
fn page_swap_updates_content_and_history() {
|
||||||
fn load_docs() -> impl IntoEffect {
|
fn load_docs() -> impl IntoEffect {
|
||||||
(
|
(
|
||||||
ui::slots::content.text("<h1>Docs</h1>"),
|
ui::slots::content.html(render_docs_content("This page was swapped.")),
|
||||||
ui::slots::title.text("Docs"),
|
ui::slots::title.text("Docs"),
|
||||||
push("/docs"),
|
push("/docs"),
|
||||||
)
|
)
|
||||||
@@ -100,9 +106,19 @@ mod tests {
|
|||||||
|
|
||||||
assert!(effect.has_slot(ui::slots::content));
|
assert!(effect.has_slot(ui::slots::content));
|
||||||
assert!(effect.has_slot(ui::slots::title));
|
assert!(effect.has_slot(ui::slots::title));
|
||||||
|
assert!(matches!(effect.ops().first(), Some(Effect::Put { payload: Payload::Html(_), .. })));
|
||||||
assert!(matches!(effect.ops().last(), Some(Effect::Navigate { url, mode: NavigateMode::Push, .. }) if url == "/docs"));
|
assert!(matches!(effect.ops().last(), Some(Effect::Navigate { url, mode: NavigateMode::Push, .. }) if url == "/docs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_docs_content(message: &'static str) -> SafeHtml {
|
||||||
|
// req: html_safety/002 req: view/001
|
||||||
|
SafeHtml::trusted(
|
||||||
|
DocsContent { message }
|
||||||
|
.render()
|
||||||
|
.expect("v0 docs content renders"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// req: examples/001 req: progressive_disclosure/001 req: build/001 req: build/005 req: codegen/004
|
// req: examples/001 req: progressive_disclosure/001 req: build/001 req: build/005 req: codegen/004
|
||||||
#[test]
|
#[test]
|
||||||
fn auth_flow_reads_typed_input_and_updates_status() {
|
fn auth_flow_reads_typed_input_and_updates_status() {
|
||||||
|
|||||||
Reference in New Issue
Block a user