-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
1 parent
7334470
commit 646757e
Showing
1 changed file
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
Phlex::SVG::StandardElements.__registered_elements__.each do |method_name, tag| | ||
test "<#{tag}> called with an underscore prefix while overridden" do | ||
example = Class.new(Phlex::SVG) do | ||
define_method :view_template do | ||
__send__("_#{method_name}") | ||
end | ||
|
||
define_method method_name do | ||
super(class: "overridden") | ||
end | ||
end | ||
|
||
expect(example.call) == %(<#{tag}></#{tag}>) | ||
end | ||
|
||
test "<#{tag}> with block text content and attributes" do | ||
example = Class.new(Phlex::SVG) do | ||
define_method :view_template do | ||
__send__(method_name, class: "class", id: "id", disabled: true, selected: false) { "content" } | ||
end | ||
end | ||
|
||
expect(example.call) == %(<#{tag} class="class" id="id" disabled>content</#{tag}>) | ||
end | ||
|
||
test "<#{tag}> with string attribute keys" do | ||
example = Class.new(Phlex::SVG) do | ||
define_method :view_template do | ||
__send__(method_name, "attribute_with_underscore" => true) { "content" } | ||
end | ||
end | ||
|
||
expect(example.call) == %(<#{tag} attribute_with_underscore>content</#{tag}>) | ||
end | ||
|
||
test "<#{tag}> with hash attribute values" do | ||
example = Class.new(Phlex::SVG) do | ||
define_method :view_template do | ||
__send__(method_name, aria: { hidden: true }, data_turbo: { frame: "_top" }) { "content" } | ||
end | ||
end | ||
|
||
expect(example.call) == %(<#{tag} aria-hidden data-turbo-frame="_top">content</#{tag}>) | ||
end | ||
end |