Skip to content

Commit

Permalink
Merge branch 'main' into release-v0.0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelpuyol authored Feb 23, 2021
2 parents 5be549d + 0dd7a30 commit 1dcfd54
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions test/components/component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,43 @@ def test_registered_components
assert_equal primer_component_files_count, COMPONENTS_WITH_ARGS.length + ignored_components.count, "Primer component added. Please update this test with an entry for your new component <3"
end

def test_primer_components_provide_a_consistent_interface
def test_all_components_support_system_arguments
COMPONENTS_WITH_ARGS.each do |component, args, proc|
# component renders hash arguments
render_component(component, { my: 4 }.merge(args), proc)
assert_selector(".my-4")
end
end

# component passes through class_names
def test_all_components_pass_through_classes
COMPONENTS_WITH_ARGS.each do |component, args, proc|
render_component(component, { classes: "foo" }.merge(args), proc)
assert_selector(".foo")
end
end

# component supports inline styles
def test_all_components_support_inline_styles
COMPONENTS_WITH_ARGS.each do |component, args, proc|
render_component(component, { style: "width: 100%;" }.merge(args), proc)
assert_selector("[style='width: 100%;']")
end
end

# component supports basic content_tag arguments
def test_all_components_support_content_tag_arguments
COMPONENTS_WITH_ARGS.each do |component, args, proc|
render_component(component, { hidden: true }.merge(args), proc)
assert_selector("[hidden]", visible: false)
end
end

def test_all_components_support_data_tag_arguments
COMPONENTS_WITH_ARGS.each do |component, args, proc|
render_component(component, { "data-ga-click": "Foo,bar" }.merge(args), proc)
assert_selector("[data-ga-click='Foo,bar']", visible: false)
end
end

# Ensure all slots accept Primer system_arguments
def test_all_slots_support_system_arguments
COMPONENTS_WITH_ARGS.each do |component, args|
next unless component.respond_to?(:slots) && component.slots.any?

result = render_inline(component.new(**args)) do |c|
Expand Down

0 comments on commit 1dcfd54

Please sign in to comment.