def test_empty_elem(self): elem = Elem('a') expected = "<a></a>" self.assertEqual(elem.to_html(), expected)
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)
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)
def test_elem(self): elem = Elem('a', {}, Elem('b', {})) expected = "<a><b></b></a>" self.assertEqual(elem.to_html(), expected)
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)
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)
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)
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)
def render(self): return Elem('a')