Skip to content

Commit

Permalink
Reorganize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv committed Feb 19, 2024
1 parent 2ce5e61 commit 31ff389
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestMultiSlotWithComponent < Minitest::Test
class Phlex::TestComponentSlotCollection < Minitest::Test
class PostComponent < Phlex::HTML
def initialize(featured: false)
@featured = featured
Expand Down Expand Up @@ -31,7 +31,7 @@ def template
end
end

def test_slots
def test_with_slots
output = Blog.new.call do |c|
c.with_post(featured: true) { "Post A" }
c.with_post { "Post B" }
Expand All @@ -51,7 +51,7 @@ def test_slots
HTML
end

def test_empty_slots
def test_with_no_slots
output = Blog.new.call

assert_equal output, "<footer>0</footer>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestMultiSlotWithString < Minitest::Test
class Phlex::TestComponentStringSlotCollection < Minitest::Test
class Blog < Phlex::HTML
include Phlex::Slotable

Expand Down Expand Up @@ -33,7 +33,7 @@ def template(&content)
end
end

def test_slots
def test_with_slots
output = Blog.new.call do |c|
c.with_post(featured: true) { "Post A" }
c.with_post { "Post B" }
Expand All @@ -53,7 +53,7 @@ def test_slots
HTML
end

def test_empty_slots
def test_with_no_slots
output = Blog.new.call

assert_equal output, "<footer>0</footer>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestMultiSlot < Minitest::Test
class Phlex::TestGenericSlotCollection < Minitest::Test
class Blog < Phlex::HTML
include Phlex::Slotable

Expand All @@ -21,7 +21,7 @@ def template
end
end

def test_slots
def test_with_slots
output = Blog.new.call do |c|
c.with_post do
c.p { "Post A" }
Expand All @@ -47,7 +47,7 @@ def test_slots
HTML
end

def test_empty_slots
def test_with_no_slots
output = Blog.new.call

assert_equal output, "<footer>0</footer>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestMultiSlotWithLambda < Minitest::Test
class Phlex::TestLambdaSlotCollection < Minitest::Test
class HeadlineComponent < Phlex::HTML
include Phlex::Slotable

Expand Down Expand Up @@ -50,7 +50,7 @@ def template
end
end

def test_slots
def test_with_slots
output = Blog.new(headline_bg_color: "blue").call do |c|
c.with_post(featured: true) { "Post A" }
c.with_post { "Post B" }
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_slots
assert_equal expected_html, output
end

def test_empty_slots
def test_with_no_slots
output = Blog.new.call

assert_equal output, "<footer>0</footer>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestMultiPolymorphicSlot < Minitest::Test
class Phlex::TestPolymorphicSlotCollection < Minitest::Test
class ImageComponent < Phlex::HTML
def initialize(src:)
@src = src
Expand Down Expand Up @@ -47,7 +47,7 @@ def template
end
end

def test_slots
def test_with_slots
output = UsersList.new.call do |c|
c.with_image_avatar(src: "user.png")
c.with_icon_avatar(name: "home")
Expand All @@ -73,7 +73,7 @@ def test_slots
HTML
end

def test_empty_slots
def test_with_no_slots
output = UsersList.new.call

assert_equal output, "<span>Users: 0</span>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestSingleSlotWithComponent < Minitest::Test
class Phlex::TestSingleComponentSlot < Minitest::Test
class HeaderComponent < Phlex::HTML
def initialize(size:)
@size = size
Expand All @@ -29,7 +29,7 @@ def template
end
end

def test_slot
def test_with_slot
output = Blog.new.call do |c|
c.with_header(size: "lg") { "Hello World!" }
end
Expand All @@ -44,7 +44,7 @@ def test_slot
HTML
end

def test_empty_slot
def test_with_no_slot
output = Blog.new.call

assert_equal output, "<main>My posts</main>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestSingleSlotWithString < Minitest::Test
class Phlex::TestSingleComponentStringSlot < Minitest::Test
class Blog < Phlex::HTML
include Phlex::Slotable

Expand Down Expand Up @@ -31,7 +31,7 @@ def template(&content)
end
end

def test_slot
def test_with_slot
output = Blog.new.call do |c|
c.with_header(size: "lg") { "Hello World!" }
end
Expand All @@ -46,7 +46,7 @@ def test_slot
HTML
end

def test_empty_slot
def test_with_no_slot
output = Blog.new.call

assert_equal output, "<main>My posts</main>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestSingleSlot < Minitest::Test
class Phlex::TestSingleGenericSlot < Minitest::Test
class Blog < Phlex::HTML
include Phlex::Slotable

Expand All @@ -19,7 +19,7 @@ def template
end
end

def test_slot
def test_with_slot
output = Blog.new.call do |c|
c.with_header do
c.h1 { "Hello World!" }
Expand All @@ -36,7 +36,7 @@ def test_slot
HTML
end

def test_empty_slot
def test_with_no_slot
output = Blog.new.call

assert_equal output, "<main>My posts</main>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class Phlex::TestSingleSlotWithLambda < Minitest::Test
class Phlex::TestSingleLambdaSlot < Minitest::Test
class SubtitleComponent < Phlex::HTML
include Phlex::Slotable

Expand Down Expand Up @@ -44,7 +44,7 @@ def template
end
end

def test_slot
def test_with_slot
output = Blog.new(subtitle_bg_color: "gray").call do |c|
c.with_title(size: :lg) { "Hello World!" }
c.with_subtitle(size: :sm) do |s|
Expand All @@ -67,7 +67,7 @@ def test_slot
HTML
end

def test_empty_slot
def test_with_no_slot
output = Blog.new.call

assert_equal output, <<~HTML.join_lines
Expand Down
6 changes: 3 additions & 3 deletions test/phlex/test_single_polymorphic_slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def template
end
end

def test_view_slot
def test_component_slot
output = ProfileCard.new.call do |c|
c.with_image_avatar(src: "user.png")
end
Expand All @@ -62,7 +62,7 @@ def test_view_slot
HTML
end

def test_string_slot
def test_component_string_slot
output = ProfileCard.new.call do |c|
c.with_icon_avatar(name: "home")
end
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_lambda_slot
HTML
end

def test_empty_slot
def test_with_no_slot
output = ProfileCard.new.call

assert_equal output, "<span>User name</span>"
Expand Down

0 comments on commit 31ff389

Please sign in to comment.