def test_widget_base_container_compile_compiles_children():
    fake_parent = BaseContainer(id='id')
    fake_parent.html_tag = 'a'

    b_elem_1 = BaseElement(id='id1', parent=fake_parent)
    b_elem_2 = BaseElement(id='id2', parent=fake_parent)

    b_elem_1.html_tag = 'b'
    b_elem_2.html_tag = 'c'

    assert fake_parent.compile(
    ) == '<a id="id"><b id="id1"></b><c id="id2"></c></a>'
def test_widget_base_container_add_child_dispatches_append():
    view_test = FakeDispatchView({
        'name': 'append',
        'html': '<x id="id">',
        'selector': '#id'
    })
    fake_parent = BaseContainer(id='id')
    fake_parent.view = view_test

    b_elem = BaseElement(id='id')
    b_elem.html_tag = 'x'
    b_elem.autoclosing = True

    fake_parent.add_child(b_elem)
    view_test.verify()
def test_widget_base_element_compile_not_autoclosing():
    b_elem = BaseElement(id='a')
    b_elem.html_tag = 'x'
    b_elem.content = "b"
    assert b_elem.compile() == '<x id="a">b</x>'
def test_widget_base_element_compile_autoclosing():
    b_elem = BaseElement(id='a')
    b_elem.html_tag = "x"
    b_elem.autoclosing = True
    assert b_elem.compile() == '<x id="a">'
def test_widget_base_element_compile_not_autoclosing():
    b_elem = BaseElement(id='a')
    b_elem.html_tag = 'x'
    b_elem.content = "b"
    assert b_elem.compile() == '<x id="a">b</x>'
def test_widget_base_element_compile_autoclosing():
    b_elem = BaseElement(id='a')
    b_elem.html_tag = "x"
    b_elem.autoclosing = True
    assert b_elem.compile() == '<x id="a">'