-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/phlex_ui/table/table_body.rb → lib/rbui/table/table_body.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/phlex_ui/table/table_caption.rb → lib/rbui/table/table_caption.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/phlex_ui/table/table_cell.rb → lib/rbui/table/table_cell.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/phlex_ui/table/table_footer.rb → lib/rbui/table/table_footer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/phlex_ui/table/table_head.rb → lib/rbui/table/table_head.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/phlex_ui/table/table_header.rb → lib/rbui/table/table_header.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class RBUI::TableTest < Minitest::Test | ||
include Phlex::Testing::ViewHelper | ||
|
||
def test_render_with_all_items | ||
invoices = [ | ||
{identifier: "INV-0001", status: "Active", method: "Credit Card", amount: 100}, | ||
{identifier: "INV-0002", status: "Active", method: "Bank Transfer", amount: 230}, | ||
{identifier: "INV-0003", status: "Pending", method: "PayPal", amount: 350}, | ||
{identifier: "INV-0004", status: "Inactive", method: "Credit Card", amount: 100} | ||
] | ||
|
||
output = phlex_context do | ||
RBUI.Table do | ||
RBUI.TableCaption { "Employees at Acme inc." } | ||
RBUI.TableHeader do | ||
RBUI.TableRow do | ||
RBUI.TableHead { "Name" } | ||
RBUI.TableHead { "Email" } | ||
RBUI.TableHead { "Status" } | ||
RBUI.TableHead(class: "text-right") { "Role" } | ||
end | ||
end | ||
RBUI.TableBody do | ||
invoices.each do |invoice| | ||
RBUI.TableRow do | ||
RBUI.TableCell(class: "font-medium") { invoice[:identifier] } | ||
RBUI.TableCell { invoice[:status] } | ||
RBUI.TableCell { invoice[:method] } | ||
RBUI.TableCell(class: "text-right") { invoice[:amount] } | ||
end | ||
end | ||
end | ||
RBUI.TableFooter do | ||
RBUI.TableRow do | ||
RBUI.TableHead(class: "font-medium", colspan: 3) { "Total" } | ||
RBUI.TableHead(class: "font-medium text-right") { invoices.sum { |invoice| invoice[:amount] } } | ||
end | ||
end | ||
end | ||
end | ||
|
||
assert_match(/Total/, output) | ||
end | ||
end |