27 lines
839 B
TypeScript
27 lines
839 B
TypeScript
import { assertEquals } from "@std/assert";
|
|
import { DocuBuilder } from "./docu_builder.ts";
|
|
|
|
Deno.test("PDF rendering loads relative assets from configured file base", async () => {
|
|
const chromiumPath = Deno.env.get("CHROMIUM_PATH");
|
|
if (!chromiumPath) {
|
|
console.warn("Skipping Chromium asset test: CHROMIUM_PATH is unset");
|
|
return;
|
|
}
|
|
|
|
const builder = new DocuBuilder({
|
|
asset_base: "../../assets",
|
|
journal: { build_js_script: false },
|
|
});
|
|
const pdfPath = await Deno.makeTempFile({ suffix: ".pdf" });
|
|
await builder.with_browser();
|
|
try {
|
|
await builder.build_as_pdf({ path: pdfPath, format: "A4" }, [
|
|
'<img src="pictures/rsf.png" alt="Asset">',
|
|
]);
|
|
} finally {
|
|
await builder.close_browser();
|
|
}
|
|
assertEquals((await Deno.stat(pdfPath)).size > 0, true);
|
|
await Deno.remove(pdfPath);
|
|
});
|