Skip to content

Commit

Permalink
Add test for the use case
Browse files Browse the repository at this point in the history
  • Loading branch information
paulchubatyy authored and dyve committed Oct 15, 2022
1 parent 030cee9 commit 1b00d5f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_bootstrap_field_radio_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class DisabledSelectTestForm(forms.Form):
widget=forms.RadioSelect,
disabled=True,
)


class SelectOtherTestForm(forms.Form):
test = forms.ChoiceField(
choices=(
(1, "one"),
(2, "two"),
),
widget=forms.RadioSelect(attrs={"form": "another-form"})


class BootstrapFieldSelectTestCase(BootstrapTestCase):
Expand Down Expand Up @@ -111,3 +120,25 @@ def test_disabled_select(self):
"</div>"
),
)

def test_other_form_select(self):
"""Test field with select that belongs to another form widget."""
self.maxDiff = None
self.assertHTMLEqual(
self.render("{% bootstrap_field form.test %}", context={"form": DisabledSelectTestForm()}),
(
'<div class="django_bootstrap5-req mb-3">'
'<label class="form-label">Test</label>'
'<div class="" disabled required id="id_test">'
'<div class="form-check">'
'<input class="form-check-input" form="another-form" type="radio" name="test" id="id_test_0" value="1">'
'<label class="form-check-label" for="id_test_0">one</label>'
"</div>"
'<div class="form-check">'
'<input class="form-check-input" form="another-form" type="radio" name="test" id="id_test_1" value="2">'
'<label class="form-check-label" for="id_test_1">two</label>'
"</div>"
"</div>"
"</div>"
),
)

0 comments on commit 1b00d5f

Please sign in to comment.