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)),), )
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
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, ) ), )
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
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, ) ), )
def test_inline(): assert matches(H.inline("thing"), "thing") assert matches(H.inline("<b>hello</b>"), "<b>hello</b>") assert matches(H.inline(H.b("hello"), H.i("there")), "<b>hello</b><i>there</i>")
def test_hrepr_multiarg(): assert hrepr(1, 2) == H.inline( H.span["hreprt-int"]("1"), H.span["hreprt-int"]("2"), )