19 lines
690 B
Python
19 lines
690 B
Python
|
|
from django.test import TestCase
|
||
|
|
from ..forms import EMPTY_ITEM_ERROR, ItemForm
|
||
|
|
|
||
|
|
class ItemFormTest(TestCase):
|
||
|
|
def test_form_item_has_placeholder_and_css_classes(self):
|
||
|
|
form = ItemForm()
|
||
|
|
rendered = form.as_p()
|
||
|
|
self.assertIn('placeholder="Enter a to-do item"', rendered)
|
||
|
|
self.assertIn('class="form-control form-control-lg"', rendered)
|
||
|
|
|
||
|
|
def test_form_validation_for_blank_items(self):
|
||
|
|
form = ItemForm(data={"text": ""})
|
||
|
|
form.save()
|
||
|
|
|
||
|
|
def test_form_validation_for_blank_items(self):
|
||
|
|
form = ItemForm(data={"text": ""})
|
||
|
|
self.assertFalse(form.is_valid())
|
||
|
|
self.assertEqual(form.errors["text"], [EMPTY_ITEM_ERROR])
|