Skip to content

Commit

Permalink
Add in a test to show the default country is correctly selected
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyChris committed May 1, 2024
1 parent 6bf01a9 commit c94160b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions django_countries/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,12 @@ def test_no_blank_choice(self):
form.fields["favourite_country"].choices[0], ("AF", "Afghanistan")
)

def test_selected_default(self):
form = forms.PersonForm()
self.assertEqual(form.fields["favourite_country"].initial, "NZ")
html = str(form["favourite_country"])
self.assertIn('<option value="NZ" selected>', html)

def test_blank_choice_label(self):
form = forms.AllowNullForm()
self.assertEqual(form.fields["country"].choices[0], ("", "(select country)"))
Expand Down

0 comments on commit c94160b

Please sign in to comment.