0
0
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:
Matt Westcott 2016-07-21 13:25:46 +01:00
parent 4a2a1cee5f
commit 5b2311e1e0

View File

@ -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):