Skip to content

Commit

Permalink
refactor: Clean up some tests (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv authored Sep 9, 2024
1 parent 28a1a3a commit 3cf6f16
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 26 deletions.
12 changes: 6 additions & 6 deletions spec/blueprint/html/attributes_parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ private class DummyPage
include Blueprint::HTML

private def blueprint
div(class: "hello", id: "first") { "Normal attributes" }
span(id: 421, float: 2.4) { "Non-string attribute values" }
section(v_model: "user.name", "@click": "doSomething") { "Transform attribute name" }
input(disabled: true, checked: false, outline: "true", border: "false")
nav(aria: {target: "#home", selected: "false", enabled: true, hidden: false}) { "Nested attributes" }
div(class: ["a", nil, "b", ["c", nil, "d"]]) { "Array attributes" }
div "Normal attributes", class: "hello", id: "first"
span "Non-string attribute values", id: 421, float: 2.4
section "Transform attribute name", v_model: "user.name", "@click": "doSomething"
input disabled: true, checked: false, outline: "true", border: "false"
nav "Nested attributes", aria: {target: "#home", selected: "false", enabled: true, hidden: false}
div "Array attributes", class: ["a", nil, "b", ["c", nil, "d"]]
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/blueprint/html/builder_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ describe Blueprint::HTML do
describe ".build" do
it "renders given html structure" do
html = Blueprint::HTML.build do
h1 { "Hello" }
h1 "Hello"

div do
span { "World" }
span "World"
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/blueprint/html/component_registrar_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private class NoBlockComponent
include Blueprint::HTML

private def blueprint
h1 { "Component without block" }
h1 "Component without block"
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/blueprint/html/conditional_rendering_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private class NoRenderPage
include Blueprint::HTML

private def blueprint
h1 { "This page will not be rendered" }
h1 "This page will not be rendered"
end

private def blueprint(&)
Expand All @@ -31,7 +31,7 @@ private class NoRenderComponent
include Blueprint::HTML

private def blueprint
h1 { "This component will not be rendered" }
h1 "This component will not be rendered"
end

private def blueprint(&)
Expand Down
4 changes: 2 additions & 2 deletions spec/blueprint/html/custom_elements_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ private class DummyPage
include Blueprint::HTML

register_element :v_btn
register_element :card, "v-card"
register_element :card, "MyCard"

private def blueprint
div do
Expand Down Expand Up @@ -37,7 +37,7 @@ describe "Blueprint::HTML custom elements registration" do
it "allows empty custom elements" do
page = DummyPage.new
expected_html = <<-HTML.strip
<v-card></v-card>
<MyCard></MyCard>
HTML

page.to_html.should contain expected_html
Expand Down
2 changes: 1 addition & 1 deletion spec/blueprint/html/enveloping_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end

private class IndexPage < BasePage
private def blueprint
h1 { "Home" }
h1 "Home"
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/blueprint/html/renderer_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ private class DummyPage
render BasicComponent.new

render ContentComponent.new do
span { "Passing content to component" }
span "Passing content to component"
end

render ComplexComponent.new do |card|
card.title { "My card" }
card.body { "Card content" }
footer { "Footer tag" }
footer "Footer tag"
end
end
end
Expand All @@ -22,7 +22,7 @@ private class BasicComponent
include Blueprint::HTML

private def blueprint
header { "Basic component" }
header "Basic component"
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/blueprint/html/utils_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ private class DummyPage
doctype
div do
plain "Hello"
b { "World" }
b "World"
end

i { "Hi" }
i "Hi"
whitespace
plain "User"

Expand Down
12 changes: 5 additions & 7 deletions spec/blueprint/html_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private class BaseLayout

html lang: "en" do
head do
title { "Test page" }
title "Test page"

meta charset: "utf-8"
meta name: "viewport", content: "width=device-width,initial-scale=1"
Expand All @@ -30,9 +30,9 @@ private class NavbarComponent
private def blueprint
nav do
ul do
li { a(href: "/home") { "Home" } }
li { a(href: "/about") { "About" } }
li { a(href: "/contact") { "Contact" } }
li { a("Home", href: "/home") }
li { a("About", href: "/about") }
li { a("Contact", href: "/contact") }
end
end
end
Expand All @@ -51,9 +51,7 @@ private class ArticleComponent
end

def title
div class: "p-2 text-lg font-bold" do
@title
end
div @title, class: "p-2 text-lg font-bold"
end

def body(&)
Expand Down

0 comments on commit 3cf6f16

Please sign in to comment.