Esempio n. 1
0
def test_custom_component_in_custom_component():
    class HelloWorldComponent(CustomComponent):
        def render(self):
            return div({"class": "foo"},
                       ["Hello", self.props.name, self.props['surname'], "."])

    class GreetComponent(CustomComponent):
        def render(self):
            # import ipdb
            # ipdb.set_trace()
            return div({}, [
                HelloWorldComponent({
                    "name": "Ustun",
                    "surname": "Ozgur"
                }, []),
                HelloWorldComponent({
                    "name": "Reyhan",
                    "surname": "Ustun"
                }, [])
            ])

    print render(GreetComponent())
    assert render_no_new_lines(GreetComponent()) == remove_new_lines(
        """<div><div class="foo">Hello Ustun Ozgur .</div><div class="foo">Hello Reyhan Ustun .</div></div>"""
    )
Esempio n. 2
0
def test_custom_component_with_single_div():
    class HelloWorld(CustomComponent):
        def render(self):
            return div({}, ["Hello World"])

    assert render(HelloWorld({}, [])) == "<div>Hello World</div>"
    assert render(HelloWorld()) == "<div>Hello World</div>"
Esempio n. 3
0
def test_custom_component_with_single_div():
    class HelloWorld(CustomComponent):

        def render(self):
            return div({}, ["Hello World"])

    assert render(HelloWorld({}, [])) == "<div>Hello World</div>"
    assert render(HelloWorld()) == "<div>Hello World</div>"
Esempio n. 4
0
def test_custom_component_in_custom_component():

    class HelloWorldComponent(CustomComponent):

        def render(self):
            return div({"class": "foo"},
                       ["Hello", self.props.name, self.props['surname'], "."])

    class GreetComponent(CustomComponent):

        def render(self):
            # import ipdb
            # ipdb.set_trace()
            return div({},
                       [HelloWorldComponent({"name": "Ustun", "surname": "Ozgur"}, []),
                        HelloWorldComponent({"name": "Reyhan", "surname": "Ustun"}, [])])

    print render(GreetComponent())
    assert render_no_new_lines(GreetComponent()) == remove_new_lines("""<div><div class="foo">Hello Ustun Ozgur .</div><div class="foo">Hello Reyhan Ustun .</div></div>""")
Esempio n. 5
0
def test_single_div_single_child_no_list_wrapping():
    assert render(div({}, "foo")) == "<div>foo</div>"
Esempio n. 6
0
def test_single_div_single_child():
    assert render(div({}, ["foo"])) == "<div>foo</div>"
Esempio n. 7
0
def test_single_div_with_children():
    assert \
        render(div({"className": "foo"},
                   [div({},
                        [span({}, ["foo"])])])) == \
        """<div class="foo"><div><span>foo</span></div></div>"""
Esempio n. 8
0
def test_single_div_single_child_single_attribute():
    assert render(div({
        "foo": "bar",
        "className": "foo bar"
    }, ["foo"])) == """<div class="foo bar" foo="bar">foo</div>"""
Esempio n. 9
0
def test_single_div_single_child_escape():
    assert render(div({}, ["<foo>"])) != "<div><foo></div>"
Esempio n. 10
0
def test_single_div_single_child_escape():
    assert render(div({}, ["<foo>"])) != "<div><foo></div>"
Esempio n. 11
0
def test_single_div_single_child_no_list_wrapping():
    assert render(div({}, "foo")) == "<div>foo</div>"
Esempio n. 12
0
def test_single_div_single_child():
    assert render(div({}, ["foo"])) == "<div>foo</div>"
Esempio n. 13
0
def test_single_div_with_children():
    assert \
        render(div({"className": "foo"},
                   [div({},
                        [span({}, ["foo"])])])) == \
        """<div class="foo"><div><span>foo</span></div></div>"""
Esempio n. 14
0
def test_single_div_single_child_single_attribute():
    assert render(div({"foo": "bar", "className": "foo bar"}, ["foo"])) == """<div class="foo bar" foo="bar">foo</div>"""