Exemplo n.º 1
0
def test_wired_renderer_simplest_init_false(registry: InjectorRegistry):
    registry.register_injectable(Person, Person)
    container = registry.create_injectable_container()
    expected = '<div>Paul Everitt</div>'
    actual = render(
        html('<{Person} first_name="Paul" last_name="Everitt"/>'),
        container=container,
    )
    assert expected == actual
Exemplo n.º 2
0
def test_wired_renderer_non_void(registry: InjectorRegistry):
    @dataclass
    class NonVoid:
        def __call__(self):
            return html('<i class="icon"></i>')

    registry.register_injectable(NonVoid, NonVoid)
    container = registry.create_injectable_container()
    expected = '<i class="icon"></i>'
    actual = render(html('<{NonVoid} />'), container=container)
    assert expected == actual
Exemplo n.º 3
0
def test_render_context():
    def App():
        message = use_context("message")
        return html("<div>{message}<//><{functional_component}/>")

    vdom = html("""
  <{Context} message='c1'>
    <{App} />
  <//>
""")
    result = render(vdom)
    expected = '<div>c1</div><h2>Functional components!</h2><span>c1</span>'
    assert result == expected
Exemplo n.º 4
0
def test_render_safe_value():
    body = Markup('<span>Escape</span>')
    vdom = html('<div>{body}</div>')
    result = render(vdom)
    expected = '<div><span>Escape</span></div>'
    assert result == expected
Exemplo n.º 5
0
def test_render_escaped_value():
    body = '<span>Escape</span>'
    vdom = html('<div>{body}</div>')
    result = render(vdom)
    expected = '<div>&lt;span&gt;Escape&lt;/span&gt;</div>'
    assert result == expected
Exemplo n.º 6
0
def test_wired_renderer_simplest_propoverride(registry: InjectorRegistry):
    registry.register_injectable(Heading, Heading)
    container = registry.create_injectable_container()
    expected = '<h1>Override</h1>'
    actual = render(html('<{Heading} name="Override"/>'), container=container)
    assert expected == actual
Exemplo n.º 7
0
def test_wired_renderer_simplest_container(registry: InjectorRegistry):
    registry.register_injectable(Heading, Heading)
    container = registry.create_injectable_container()
    expected = '<h1>Hello</h1>'
    actual = render(html('''<{Heading}/>'''), container=container)
    assert expected == actual
Exemplo n.º 8
0
def test_wired_renderer_simplest_nocontainer():
    instance = Heading(name='No Wired')
    expected = '<h1>No Wired</h1>'
    actual = render(instance())
    assert expected == actual