// A heading's own bold run is only "what the style supplies" where the editor's bold // built-in still renders it — a file declaring its own heading style re-parents it. import { describe, it, expect } from 'vitest'; import { zipSync, strToU8 } from 'fflate'; import { importDocx } from '../../src/lib/import/docx'; import { importOdt } from '../../src/lib/import/odt'; import { buildOdt } from '../../src/lib/export/odt'; const W = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'; const docx = (styles: string) => zipSync({ 'word/document.xml': strToU8(` Title `), 'word/styles.xml': strToU8(` ${styles} `), }); const HEADING_BASED = '' + '' + ''; const HEADING_ROOT = HEADING_BASED.replace('', ''); const marks = (doc: any) => JSON.stringify(doc.content.content[0].content[0].marks ?? []); describe('heading bold', () => { it('keeps the run mark where the file re-parents its heading style (DOCX)', () => { expect(marks(importDocx(docx(HEADING_BASED)))).toContain('bold'); }); it('drops it where the bold built-in renders the heading (DOCX)', () => { expect(marks(importDocx(docx(HEADING_ROOT)))).not.toContain('bold'); }); it('survives the ODT round trip under a re-parented heading style', async () => { const res: any = importDocx(docx(HEADING_BASED)); const m = { top: 2, bottom: 2, left: 2, right: 2 }; const back: any = importOdt(await buildOdt(res.content, m, 'portrait', undefined, undefined, 'A4', res.styles)); expect(marks(back)).toContain('bold'); }); });