Skip to content

Commit

Permalink
Add test cases for nebulab#37
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaier committed Aug 25, 2024
1 parent f4fc48d commit 5e7690b
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/erb/test_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,65 @@ def test_format_ruby_with_long_lines_and_larger_line_width
)
end

def test_format_ruby_with_block
input = <<~ERB.chomp
<%=
render FooComponent.new(title: t('.page_title')) do |c|
c.with_body.with_content(t('.intro_html'))
end
%>
ERB

expected_output = <<~ERB.chomp
<%= render FooComponent.new(title: t(".page_title")) do |c|
c.with_body.with_content(t(".intro_html"))
end %>
ERB

assert_equal(expected_output, ERB::Formatter.format(input).strip)
end

def test_format_ruby_with_block_with_parantheses
input = <<~ERB.chomp
<%=
render(FooComponent.new(title: t('.page_title')) do |c|
c.with_body.with_content(t('.intro_html'))
end)
%>
ERB

expected_output = <<~ERB.chomp
<%= render(
FooComponent.new(title: t(".page_title")) do |c|
c.with_body.with_content(t(".intro_html"))
end,
) %>
ERB

assert_equal(expected_output, ERB::Formatter.format(input).strip)
end

def test_format_ruby_with_block_with_variable
input = <<~ERB.chomp
<%=
component = FooComponent.new(title: t('.page_title')) do |c|
c.with_body.with_content(t('.intro_html'))
end
render component
%>
ERB

expected_output = <<~ERB.chomp
<%= component =
FooComponent.new(title: t(".page_title")) do |c|
c.with_body.with_content(t(".intro_html"))
end
render component %>
ERB

assert_equal(expected_output, ERB::Formatter.format(input).strip)
end

def test_tailwindcss_class_sorting
require 'tailwindcss-rails'
require 'erb/formatter/command_line'
Expand Down

0 comments on commit 5e7690b

Please sign in to comment.