Example #1
0
    def test_empty_elem(self):

        elem = Elem('a')

        expected = "<a></a>"

        self.assertEqual(elem.to_html(), expected)
Example #2
0
    def test_elem_with_text_child(self):

        elem = Elem('a', {}, 'My link text')

        expected = "<a>My link text</a>"

        self.assertEqual(elem.to_html(), expected)
Example #3
0
    def test_elem_single_attribute(self):

        elem = Elem('a', {'class': 'some-icon'}, Elem('b', {}))

        expected = '<a class="some-icon"><b></b></a>'

        self.assertEqual(elem.to_html(), expected)
Example #4
0
    def test_elem(self):

        elem = Elem('a', {}, Elem('b', {}))

        expected = "<a><b></b></a>"

        self.assertEqual(elem.to_html(), expected)
Example #5
0
    def test_simple_component(self):
        class MyComponent(object):
            def render(self):
                return Elem('a')

        elem = Elem(MyComponent)

        expected = "<a></a>"

        self.assertEqual(elem.to_html(), expected)
Example #6
0
    def test_props(self):
        class MyComponent(Component):
            def render(self):
                return 'My test property value: %s' % self.props['test']

        elem = Elem(MyComponent, {'test': 'test_value'})

        expected = 'My test property value: test_value'

        self.assertEqual(elem.to_html(), expected)
Example #7
0
    def test_text_component(self):
        class MyComponent(object):
            def render(self):
                return 'Just some text'

        elem = Elem(MyComponent)

        expected = 'Just some text'

        self.assertEqual(elem.to_html(), expected)
Example #8
0
    def test_elem_multiple_attribute(self):

        elem = Elem('a', {
            'class': 'some-icon',
            'data-width': 800
        }, Elem('b', {}))

        expected = '<a data-width="800" class="some-icon"><b></b></a>'

        self.assertEqual(elem.to_html(), expected)
Example #9
0
    def test_props(self):

        class MyComponent(Component):

            def render(self):
                return 'My test property value: %s' % self.props['test']

        elem = Elem(MyComponent, {'test': 'test_value'})

        expected = 'My test property value: test_value'

        self.assertEqual(elem.to_html(), expected)
Example #10
0
    def test_text_component(self):

        class MyComponent(object):

            def render(self):
                return 'Just some text'

        elem = Elem(MyComponent)

        expected = 'Just some text'

        self.assertEqual(elem.to_html(), expected)
Example #11
0
    def test_simple_component(self):

        class MyComponent(object):

            def render(self):
                return Elem('a')

        elem = Elem(MyComponent)

        expected = "<a></a>"

        self.assertEqual(elem.to_html(), expected)
Example #12
0
 def render(self):
     return Elem('a')