mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 17:36:49 +01:00
Add test for presence of 'required' class
This commit is contained in:
parent
4a2a1cee5f
commit
5b2311e1e0
@ -901,8 +901,8 @@ class TestStructBlock(SimpleTestCase):
|
||||
|
||||
def test_render_form(self):
|
||||
class LinkBlock(blocks.StructBlock):
|
||||
title = blocks.CharBlock()
|
||||
link = blocks.URLBlock()
|
||||
title = blocks.CharBlock(required=False)
|
||||
link = blocks.URLBlock(required=False)
|
||||
|
||||
block = LinkBlock()
|
||||
html = block.render_form(block.to_python({
|
||||
@ -924,6 +924,20 @@ class TestStructBlock(SimpleTestCase):
|
||||
),
|
||||
html
|
||||
)
|
||||
self.assertNotIn('<li class="required">', html)
|
||||
|
||||
def test_render_required_field_indicator(self):
|
||||
class LinkBlock(blocks.StructBlock):
|
||||
title = blocks.CharBlock()
|
||||
link = blocks.URLBlock(required=True)
|
||||
|
||||
block = LinkBlock()
|
||||
html = block.render_form(block.to_python({
|
||||
'title': "Wagtail site",
|
||||
'link': 'http://www.wagtail.io',
|
||||
}), prefix='mylink')
|
||||
|
||||
self.assertIn('<li class="required">', html)
|
||||
|
||||
def test_render_form_unknown_field(self):
|
||||
class LinkBlock(blocks.StructBlock):
|
||||
|
Loading…
Reference in New Issue
Block a user