/** * @vitest-environment jsdom */ import { describe, expect, it } from 'vitest' import { buildPresentation } from '@/lib/pptx-renderer/model/presentation' import type { PptxFiles } from '@/lib/pptx-renderer/parser/zip-parser' function createFiles(presentation: string): PptxFiles { return { contentTypes: '', presentation, presentationRels: ` `, slides: new Map([ ['ppt/slides/slide1.xml', createSlideXml()], ['ppt/slides/slide2.xml', createSlideXml()], ]), slideRels: new Map([ ['ppt/slides/_rels/slide1.xml.rels', ''], ['ppt/slides/_rels/slide2.xml.rels', ''], ]), slideLayouts: new Map(), slideLayoutRels: new Map(), slideMasters: new Map(), slideMasterRels: new Map(), themes: new Map(), media: new Map(), charts: new Map(), chartStyles: new Map(), chartColors: new Map(), diagramDrawings: new Map(), } } function createPresentationXml(markers = ''): string { return ` ` } function createSlideXml(): string { return ` ` } describe('buildPresentation', () => { it('does not treat the standard wps namespace prefix as WPS Office', () => { const presentation = buildPresentation( createFiles( createPresentationXml( 'xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"' ) ) ) expect(presentation.isWps).toBe(false) }) it('orders slides by relationship id instead of numeric slide id', () => { const presentation = buildPresentation(createFiles(createPresentationXml())) expect(presentation.slides.map((slide) => slide.slidePath)).toEqual([ 'ppt/slides/slide2.xml', 'ppt/slides/slide1.xml', ]) }) })