from . import CommonTestCase

from ..controls import StringControl


class InputCounterTestCase(CommonTestCase):

    def setUp(self):
        super(InputCounterTestCase, self).setUp()
        self.control = self.builder.controls['input-counter']

    def test_control(self):
        self.assertIsInstance(self.control, StringControl)

    def test_builder_bind(self):
        self.assertEqual(self.control.bind.id, 'input-counter-bind')
        self.assertEqual(self.control.bind.name, 'input-counter')

    def test_builder_form(self):
        self.assertEqual(self.control.label, 'Input Field with Character Counter')
        self.assertEqual(self.control.alert, '30 characters maximum')
        self.assertEqual(self.control.hint, None)

        self.assertEqual(self.control.element.label, 'Input Field with Character Counter')
        self.assertEqual(self.control.element.alert, '30 characters maximum')
        self.assertEqual(self.control.element.hint, None)

    def test_builder_form_default_value(self):
        self.assertEqual(self.control.default_raw_value, 'This must not be "too long"!')
        self.assertEqual(self.control.default_value, 'This must not be "too long"!')

    def test_runner_input_counter(self):
        text = "Don't even try to make it too long!"
        self.assertEqual(self.runner.get_value('input-counter'), text)
        self.assertEqual(self.runner.form.inputcounter.value, text)

@@ -1218,16 +1218,22 @@
 _counter
+_value
 (self):%0A
@@ -1355,16 +1355,217 @@
 ), text)
+%0A%0A    def test_runner_input_counter_form(self):%0A        self.assertEqual(self.runner.form.inputcounter.label, 'Input Field with Character Counter')%0A%0A        text = %22Don't even try to make it too long!%22
 %0A       

Complete the test_input_counter.