Skip to content

Commit

Permalink
Refactor test classes (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv authored Nov 14, 2024
1 parent 936b739 commit a118d54
Show file tree
Hide file tree
Showing 38 changed files with 93 additions and 171 deletions.
8 changes: 3 additions & 5 deletions test/ruby_ui/accordion_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::AccordionTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::AccordionTest < ComponentTest
def test_render_with_default_items
output = phlex_context do
output = phlex do
RubyUI.Accordion do
RubyUI.AccordionItem do
RubyUI.AccordionDefaultTrigger { "Title" }
Expand All @@ -19,7 +17,7 @@ def test_render_with_default_items
end

def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Accordion do
RubyUI.AccordionItem do
RubyUI.AccordionTrigger do |trigger|
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/alert_dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::AlertDialogTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::AlertDialogTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.AlertDialog do
RubyUI.AlertDialogTrigger do
RubyUI.Button { "Show dialog" }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/alert_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::AlertTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::AlertTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Alert do
RubyUI.AlertTitle { "Pro tip" }
RubyUI.AlertDescription { "Simply, don't include an icon and your alert will look like this." }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/aspect_ratio_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::AspectRatioTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::AspectRatioTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.AspectRatio(aspect_ratio: "16/9") do |aspect|
aspect.img(
alt: "Placeholder",
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/avatar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::AvatarTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::AvatarTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Avatar do
RubyUI.AvatarImage(src: "https://avatars.githubusercontent.com/u/246692?v=4", alt: "joeldrapper")
RubyUI.AvatarFallback { "JD" }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/badge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::BadgeTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::BadgeTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Badge { "Badge" }
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/button_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::ButtonTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::ButtonTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Button(variant: :primary) { "Primary" }
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/calendar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::CalendarTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::CalendarTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Input(type: "string", placeholder: "Select a date", class: "rounded-md border shadow", id: "date", data_controller: "ruby-ui--input")
RubyUI.Calendar(input_id: "#date", class: "rounded-md border shadow")
end
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/card_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::CardTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::CardTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Card(class: "w-96") do
RubyUI.CardHeader do
RubyUI.CardTitle { 'You might like "RubyUI"' }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/chart_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::ChartTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::ChartTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
options = {
type: "bar",
data: {
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/checkbox_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::CheckboxTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::CheckboxTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Checkbox(id: "terms")
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/clipboard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::ClipboardTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::ClipboardTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Clipboard(success: "Copied!", error: "Copy Failed!")
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/codeblock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

require "test_helper"

class RubyUI::CodeblockTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::CodeblockTest < ComponentTest
def test_render_with_all_items
code = <<~CODE
def hello_world
puts "Hello, world!"
end
CODE

output = phlex_context do
output = phlex do
RubyUI.Codeblock(code, syntax: :ruby)
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/collapsible_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::CollapsibleTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::CollapsibleTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Collapsible(open: true) do
RubyUI.CollapsibleTrigger do
RubyUI.Button(variant: :ghost, icon: true) do |button|
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/combobox_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::ComboboxTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::ComboboxTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Combobox do
RubyUI.ComboboxInput()
RubyUI.ComboboxTrigger do
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/command_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

require "test_helper"

class RubyUI::CommandTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::CommandTest < ComponentTest
def test_render_with_all_items
components_list = [
{name: "Accordion", path: "#"},
Expand All @@ -21,7 +19,7 @@ def test_render_with_all_items
{name: "Settings", path: "#"}
]

output = phlex_context do
output = phlex do
RubyUI.CommandDialog do
RubyUI.CommandDialogTrigger do
RubyUI.Button(variant: "outline", class: "w-56 pr-2 pl-3 justify-between") do |button|
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/context_menu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::ContextMenuTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::ContextMenuTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.ContextMenu do
RubyUI.ContextMenuTrigger(class: "flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm") { "Right click here" }
RubyUI.ContextMenuContent(class: "w-64") do
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::DialogTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::DialogTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Dialog do
RubyUI.DialogTrigger do
RubyUI.Button { "Open Dialog" }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/dropdown_menu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::DropdownMenuTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::DropdownMenuTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.DropdownMenu do
RubyUI.DropdownMenuTrigger(class: "w-full") do
RubyUI.Button(variant: :outline) { "Open" }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::FormTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::FormTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Form do
RubyUI.FormField do
RubyUI.FormFieldLabel { "Label" }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/hover_card_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::HoverCardTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::HoverCardTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.HoverCard do
RubyUI.HoverCardTrigger do
RubyUI.Button(variant: :link) { "@joeldrapper" }
Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/inline_code_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::InlineCodeTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::InlineCodeTest < ComponentTest
def test_render_inline_code
output = phlex_context do
output = phlex do
RubyUI::InlineCode() { "This is an inline code block" }
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/inline_link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::InlineLinkTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::InlineLinkTest < ComponentTest
def test_render_inline_link
output = phlex_context do
output = phlex do
RubyUI::InlineLink(href: "#") { "Link" }
end

Expand Down
8 changes: 3 additions & 5 deletions test/ruby_ui/input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

require "test_helper"

class RubyUI::InputTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::InputTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Input(type: "email", placeholder: "Email")
end

assert_match(/Email/, output)
end

def test_render_with_value
output = phlex_context do
output = phlex do
RubyUI.Input(type: "email", value: "[email protected]")
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::LinkTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::LinkTest < ComponentTest
def test_render_with_all_items
output = phlex_context do
output = phlex do
RubyUI.Link(href: "#") { "Link" }
end

Expand Down
6 changes: 2 additions & 4 deletions test/ruby_ui/masked_input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

require "test_helper"

class RubyUI::MaskedInputTest < Minitest::Test
include Phlex::Testing::ViewHelper

class RubyUI::MaskedInputTest < ComponentTest
def test_render
output = phlex_context do
output = phlex do
RubyUI.MaskedInput(data: {maska: "#####-###"})
end

Expand Down
Loading

0 comments on commit a118d54

Please sign in to comment.