diff --git a/test/components/component_test.rb b/test/components/component_test.rb index 6845267792..5e70f0332f 100644 --- a/test/components/component_test.rb +++ b/test/components/component_test.rb @@ -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|