|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require "components/test_helper" |
| 4 | + |
| 5 | +class PrimerOpenProjectFieldsetTest < Minitest::Test |
| 6 | + include Primer::ComponentTestHelpers |
| 7 | + |
| 8 | + |
| 9 | + def test_renders_fieldset_with_legend_slot_and_text_param |
| 10 | + render_inline(Primer::OpenProject::Fieldset.new) do |component| |
| 11 | + component.with_legend(text: "My legend") |
| 12 | + "Fieldset content" |
| 13 | + end |
| 14 | + |
| 15 | + assert_selector("fieldset") do |
| 16 | + assert_selector("legend", text: "My legend") |
| 17 | + assert_text("Fieldset content") |
| 18 | + end |
| 19 | + end |
| 20 | + |
| 21 | + def test_renders_fieldset_with_legend_slot_and_content |
| 22 | + render_inline(Primer::OpenProject::Fieldset.new) do |component| |
| 23 | + component.with_legend { "My legend" } |
| 24 | + "Fieldset content" |
| 25 | + end |
| 26 | + |
| 27 | + assert_selector("fieldset") do |
| 28 | + assert_selector("legend", text: "My legend") |
| 29 | + assert_text("Fieldset content") |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + def test_renders_fieldset_with_legend_text_param |
| 34 | + render_inline(Primer::OpenProject::Fieldset.new(legend_text: "My legend")) do |
| 35 | + "Fieldset content" |
| 36 | + end |
| 37 | + |
| 38 | + assert_selector("fieldset") do |
| 39 | + assert_selector("legend", text: "My legend") |
| 40 | + assert_text("Fieldset content") |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + def test_renders_nothing_without_legend_slot_or_legend_text |
| 45 | + render_inline(Primer::OpenProject::Fieldset.new) do |
| 46 | + "Fieldset content" |
| 47 | + end |
| 48 | + |
| 49 | + assert_no_selector("fieldset") |
| 50 | + assert_no_text("Fieldset content") |
| 51 | + end |
| 52 | + |
| 53 | + def test_renders_nothing_without_content |
| 54 | + render_inline(Primer::OpenProject::Fieldset.new(legend_text: "My legend")) |
| 55 | + |
| 56 | + assert_no_selector("fieldset") |
| 57 | + assert_no_text("My legend") |
| 58 | + end |
| 59 | +end |
0 commit comments