diff --git a/CHANGELOG.md b/CHANGELOG.md index ff8523e..b06fadd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). input, and `patch_svg` on synthetic 200- and 1000-path SVGs. - Stress tests: 5000-deep nesting, 2000-attribute element, ~470KB synthetic SVG patching, 9KB metacharacter round-trip parity, - MIME show round-trip parity. + and one canonical fixture pinned across `MIME"text/html"`, + `MIME"text/plain"`, and `html_response(...).body`. - `precompile()` block in the module top so the first `render(...)` in a user's session doesn't pay JIT cost for the common shapes. diff --git a/test/runtests.jl b/test/runtests.jl index 2245937..81ca2ba 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1170,6 +1170,27 @@ using HyperSignal: div, select, summary @test String(take!(io)) == "x" end + @testset "one fixture stays byte-stable across text/html, text/plain, and HTTP.Response sinks" begin + # Why: these are the three places callers actually consume a + # HyperSignal value — notebook display, REPL/plain-text display, + # and an HTTP response body. One canonical fixture should say they + # all agree on the rendered bytes. + el = div(class="card", h2("Hi"), p("a < b")) + html = render(el) + + html_io = IOBuffer() + show(html_io, MIME"text/html"(), el) + @test String(take!(html_io)) == html + + plain_io = IOBuffer() + show(plain_io, MIME"text/plain"(), el) + @test String(take!(plain_io)) == "HyperSignal.Element: " * html + + resp = html_response(el) + @test resp.body == codeunits(html) + @test String(resp.body) == html + end + @testset "patch_svg with CairoMakie figure renders + namespaces collision-safely" begin # Why: prove the front-row CairoMakie story actually works end-to-end # — produce a real figure, run it through inline_svg, drop two of