0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Add tests for new date/time widget behaviour

This commit is contained in:
jacobtoppm 2020-05-22 11:20:09 +01:00 committed by Matt Westcott
parent 38f18ae98b
commit ba4a72d867

View File

@ -153,17 +153,22 @@ class TestAdminDateTimeInput(TestCase):
self.assertIn('initDateTimeChooser("test\\u002Did", {', html)
self.assertIn('"dayOfWeekStart": 0', html)
self.assertIn('"format": "Y-m-d H:i"', html)
self.assertIn('"formatTime": "H:i"', html)
def test_render_js_init_with_format(self):
widget = widgets.AdminDateTimeInput(format='%d.%m.%Y. %H:%M')
widget = widgets.AdminDateTimeInput(format='%d.%m.%Y. %H:%M', time_format='%H:%M %p')
html = widget.render('test', None, attrs={'id': 'test-id'})
self.assertIn(
'"format": "d.m.Y. H:i"',
html,
)
self.assertIn(
'"formatTime": "H:i A"',
html,
)
@override_settings(WAGTAIL_DATETIME_FORMAT='%d.%m.%Y. %H:%M')
@override_settings(WAGTAIL_DATETIME_FORMAT='%d.%m.%Y. %H:%M', WAGTAIL_TIME_FORMAT='%H:%M %p')
def test_render_js_init_with_format_from_settings(self):
widget = widgets.AdminDateTimeInput()
@ -172,6 +177,10 @@ class TestAdminDateTimeInput(TestCase):
'"format": "d.m.Y. H:i"',
html,
)
self.assertIn(
'"formatTime": "H:i A"',
html,
)
class TestAdminTagWidget(TestCase):