=> {
+ const zip = new JSZip();
+ const slideXml = (title: string, body: string[] = []) => {
+ const titleP = `${title}`;
+ const bodyPs = body.map((b) => `${b}`).join('');
+ return `
+
+ ${titleP}${bodyPs}
+`;
+ };
+ slides.forEach((s, i) => {
+ zip.file(`ppt/slides/slide${i + 1}.xml`, slideXml(s.title, s.body));
+ });
+ zip.file('docProps/core.xml', '');
+ return zip.generateAsync({ type: 'nodebuffer' });
+ };
+
+ test('routes a small pptx (≤ cap) through the CDN-rendered path', async () => {
+ const pptx = await buildPptx([{ title: 'Hello', body: ['First slide'] }]);
+ const html = await pptxToHtml(pptx);
+ expect(html).toMatch(/^/);
+ expect(html).toContain('id="lc-doc-data"');
+ expect(html).toContain('pptxPreview.init');
+ expect(html).toContain('cdn.jsdelivr.net/npm/pptx-preview@');
+ // Slide-list signature must NOT appear (those are ).
+ expect(html).not.toContain('class="lc-pptx-list"');
+ });
+
+ describe('CDN-rendered path', () => {
+ test('embeds the binary as base64 that round-trips to the original bytes', async () => {
+ const original = await buildPptx([{ title: 'Test' }]);
+ const html = await _internal.pptxToHtmlViaCdn(original);
+ const match = html.match(
+ /
+
+
+
+Preview unavailable. Please download the file to view it.
+
+
+
+