Skip to content

Commit

Permalink
add test for custom
Browse files Browse the repository at this point in the history
  • Loading branch information
eliknebel committed Mar 13, 2024
1 parent fc70dcb commit f57048d
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions test/sprocket/reconcilers/recursive_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import gleeunit/should
import ids/cuid
import sprocket/context.{type Context, type Element}
import sprocket/component.{component, render}
import sprocket/html/elements.{a, div, fragment, text}
import sprocket/html/elements.{a, div, fragment, raw, text}
import sprocket/html/attributes.{class, classes}
import sprocket/hooks.{handler, provider}
import sprocket/internal/reconcilers/recursive.{reconcile}
import sprocket/internal/reconcile.{
type ReconciledElement, ReconciledAttribute, ReconciledComponent,
ReconciledElement, ReconciledEventHandler, ReconciledFragment,
ReconciledResult, ReconciledText,
ReconciledCustom, ReconciledElement, ReconciledEventHandler,
ReconciledFragment, ReconciledResult, ReconciledText,
}

// Renders the given element as a stateless element to html.
Expand Down Expand Up @@ -256,3 +256,33 @@ pub fn renders_component_with_context_provider_test() {
],
) = rendered
}

type EmptyProps {
EmptyProps
}

fn test_component_with_custom_element(ctx: Context, _props) {
render(
ctx,
raw(
"div",
"An unescaped <b>raw <em>html</em></b> <span style=\"color: blue\">string</span></b>",
),
)
}

pub fn renders_test_component_with_custom_element_test() {
let rendered =
render_el(component(test_component_with_custom_element, EmptyProps))

let assert ReconciledComponent(
_fc,
_key,
_props,
_hooks,
ReconciledCustom(
kind: "raw",
data: "{\"tag\":\"div\",\"innerHtml\":\"An unescaped <b>raw <em>html</em></b> <span style=\\\"color: blue\\\">string</span></b>\"}",
),
) = rendered
}

0 comments on commit f57048d

Please sign in to comment.