CODE · 0.9 KB
test/pptx-preflight.test.js
Workspace snapshot · 09/04 13:45
import test from "node:test";
import assert from "node:assert/strict";
import JSZip from "jszip";
import { analyzePptx } from "../src/pptx-preflight.js";
const deck=async(slides)=>{const zip=new JSZip();slides.forEach((xml,index)=>zip.file(`ppt/slides/slide${index+1}.xml`,xml));return zip.generateAsync({type:"arraybuffer"});};
test("reports editable text and common fonts as healthy",async()=>{const result=await analyzePptx(await deck(['<p:sld><p:sp><a:rPr typeface="Arial"/><a:t>編集できる提案</a:t></p:sp></p:sld>']));assert.equal(result.slideCount,1);assert.equal(result.score,100);assert.equal(result.slides[0].textElements,1);});
test("flags flattened image slides and custom fonts",async()=>{const result=await analyzePptx(await deck(['<p:sld><p:pic></p:pic><p:sp><a:rPr typeface="Brand Font"/></p:sp></p:sld>']));assert.ok(result.score<85);assert.deepEqual(result.customFonts,["Brand Font"]);assert.equal(result.slides[0].risks.length,1);});