From a395a5b710673a53ace7d5dc0bf0d7b06ca88da8 Mon Sep 17 00:00:00 2001 From: stephann <3025661+stephannv@users.noreply.github.com> Date: Mon, 14 Jul 2025 20:41:48 -0300 Subject: [PATCH] Improve tests --- .../html/attributes_handling_spec.cr | 12 +++++++++++ ...ration_spec.cr => custom_elements_spec.cr} | 21 +++++++++++++++++-- spec/blueprint/html/svg_spec.cr | 8 +++++-- src/blueprint/html/svg.cr | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) rename spec/blueprint/html/{custom_elements_registration_spec.cr => custom_elements_spec.cr} (67%) diff --git a/spec/blueprint/html/attributes_handling_spec.cr b/spec/blueprint/html/attributes_handling_spec.cr index 6c0e00a..eab94d2 100644 --- a/spec/blueprint/html/attributes_handling_spec.cr +++ b/spec/blueprint/html/attributes_handling_spec.cr @@ -55,6 +55,18 @@ describe "attributes handling" do actual_html.should eq expected_html end + it "doesn't render nil attributes" do + actual_html = Blueprint::HTML.build do + div class: nil, data: {id: nil} + end + + expected_html = normalize_html <<-HTML +
+ HTML + + actual_html.should eq expected_html + end + it "expands NamedTuple attributes" do actual_html = Blueprint::HTML.build do nav aria: {target: "#home", selected: "false", enabled: true, hidden: false} do diff --git a/spec/blueprint/html/custom_elements_registration_spec.cr b/spec/blueprint/html/custom_elements_spec.cr similarity index 67% rename from spec/blueprint/html/custom_elements_registration_spec.cr rename to spec/blueprint/html/custom_elements_spec.cr index 067e884..2fbe53f 100644 --- a/spec/blueprint/html/custom_elements_registration_spec.cr +++ b/spec/blueprint/html/custom_elements_spec.cr @@ -11,8 +11,25 @@ private class Example end end -describe "custom elements registration" do - it "allows custom elements definition" do +describe "custom elements" do + it "allows custom elements rendering" do + actual_html = Blueprint::HTML.build do + element :foo, class: "bar", data: {tmp: true} do + "Hello" + end + + void_element :portal, class: "my-portal" + end + + expected_html = normalize_html <<-HTML +