release: WRNexusJS 0.3.0
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { renderDocument } from "../src/index.ts";
|
||||
import { renderDocument, renderDocumentStream } from "../src/index.ts";
|
||||
|
||||
test("escapes metadata and script URLs while preserving trusted rendered body", () => {
|
||||
const html = renderDocument({
|
||||
@@ -35,3 +35,14 @@ test("always emits a document language and preserves an explicit language", () =
|
||||
expect(explicit).toContain('<html data-theme="dark" lang="fr">');
|
||||
expect(explicit).not.toContain('lang="en"');
|
||||
});
|
||||
|
||||
test("streams async body chunks inside the document shell", async () => {
|
||||
async function* body() {
|
||||
yield "<h1>Shell</h1>";
|
||||
yield "<p>Later</p>";
|
||||
}
|
||||
const html = await new Response(
|
||||
renderDocumentStream({ meta: { title: "Stream" }, body: body() }),
|
||||
).text();
|
||||
expect(html).toContain('<div id="app"><h1>Shell</h1><p>Later</p></div>');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user