Exemplo n.º 1
0
def test_as_page():
    utf8 = H.meta(
        {"http-equiv": "Content-type"}, content="text/html", charset="UTF-8"
    )
    assert real_hrepr.page(1) == H.inline(
        H.raw("<!DOCTYPE html>"),
        H.html(H.head(utf8, H.style(css_hrepr)), H.body(real_hrepr(1)),),
    )
Exemplo n.º 2
0
def test_as_page():
    tag = H.div("simplicity")
    utf8 = H.meta({"http-equiv": "Content-type"},
                  content="text/html",
                  charset="UTF-8")
    page = H.inline(
        H.raw("<!DOCTYPE html>"),
        H.html(H.head(utf8), H.body(tag)),
    )
    assert tag.as_page() == page
Exemplo n.º 3
0
def test_constructed_element():
    assert sht(
        H.div["chapeau"](id="melon", constructor="fou", options={"x": 1},)
    ) == H.inline(
        H.div["chapeau"](id="melon"),
        sht(
            H.javascript(
                "new fou(document.getElementById('melon'), {\"x\": 1});",
                require="fou",
                lazy=False,
            )
        ),
    )
Exemplo n.º 4
0
def test_as_page_with_resources():
    sty = H.style("b { color: red; }")
    scr = H.script("x = 1234;")
    resources = (sty, scr)
    inner = H.b("resources").fill(resources=scr)
    tag = H.div("with ", inner).fill(resources=sty)
    utf8 = H.meta({"http-equiv": "Content-type"},
                  content="text/html",
                  charset="UTF-8")
    page = H.inline(
        H.raw("<!DOCTYPE html>"),
        H.html(H.head(utf8, *resources), H.body(tag)),
    )
    assert tag.as_page() == page
Exemplo n.º 5
0
def test_constructed_special_element():
    assert sht(
        H.atom(
            id="melon",
            type="cool",
            constructor="fou",
            options={"x": 1},
            export="everywhere",
        )
    ) == H.inline(
        H.span["hreprt-cool"](id="melon"),
        sht(
            H.javascript(
                "let everywhere = new fou(document.getElementById('melon'), {\"x\": 1});",
                require="fou",
                export="everywhere",
                lazy=False,
            )
        ),
    )
Exemplo n.º 6
0
def test_inline():
    assert matches(H.inline("thing"), "thing")
    assert matches(H.inline("<b>hello</b>"), "&lt;b&gt;hello&lt;/b&gt;")
    assert matches(H.inline(H.b("hello"), H.i("there")),
                   "<b>hello</b><i>there</i>")
Exemplo n.º 7
0
def test_hrepr_multiarg():
    assert hrepr(1, 2) == H.inline(
        H.span["hreprt-int"]("1"), H.span["hreprt-int"]("2"),
    )