Skip to content

Commit 2baac89

Browse files
committed
Option and build_attrs tests
1 parent 6fa892f commit 2baac89

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

testapp/tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import html5lib
44
from django.test import TestCase
55

6+
from intl_tel_input.widgets import IntlTelInputWidget
7+
68

79
class IntlTelInputTest(TestCase):
810
def assertValidHTML(self, content, msg=None):
@@ -39,7 +41,14 @@ def test_with_attrs(self):
3941
r = self.client.get('/attrs-test/')
4042
self.assertIn('title="Telephone number"', r.content.decode('utf-8'))
4143
self.assertIn('data-default-code="jp"', r.content.decode('utf-8'))
44+
self.assertIn('data-preferred-countries="["jp"]"',
45+
r.content.decode('utf-8'))
4246

4347
def test_with_initial(self):
4448
r = self.client.get('/initial-test/')
4549
self.assertIn('value="+81123456789"', r.content.decode('utf-8'))
50+
51+
def test_extra_attrs(self):
52+
widget = IntlTelInputWidget()
53+
attrs = widget.build_attrs(extra_attrs={'required': True})
54+
self.assertTrue(attrs['required'])

0 commit comments

Comments
 (0)