Files
edentext/tests/unit/odt-page-break-export.test.ts
T
Steffen Becker a7fe334900 test: widen the fuzz generator to effects, links, notes and cell props
New in the pool: underline/strike line styles, super/subscript, caps,
textPosition, links, page breaks, footnotes/endnotes, cell shading and
vertical alignment. normalize() canonicalizes importer-generated note ids and
drops the link mark's default plain:false; FUZZ_SEEDS widens the sweep beyond
the default 50. This is the suite that surfaced the last four export/import
fixes; all 300 sweep seeds now round-trip clean on both legs.
2026-08-16 07:50:22 +02:00

25 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { unzipSync, strFromU8 } from 'fflate';
import { buildOdt } from '../../src/lib/export/odt';
// A document odf-kit mints no automatic style for carries `<office:automatic-styles/>`,
// self-closed — replacing the closing tag silently dropped every minted style there,
// so a manual page break exported as a plain paragraph.
const doc = {
type: 'doc',
content: [
{ type: 'paragraph', content: [{ type: 'text', text: 'one' }] },
{ type: 'paragraph', attrs: { breakBefore: 'page' }, content: [{ type: 'text', text: 'two' }] },
],
};
describe('ODF page break export', () => {
it('mints the break style even with no automatic styles section', async () => {
const bytes = await buildOdt(doc as never, undefined, 'portrait');
const content = strFromU8(unzipSync(bytes)['content.xml']);
const name = /style:name="(PBK\d+)"[^>]*>\s*<style:paragraph-properties fo:break-before="page"/.exec(content)?.[1];
expect(name).toBeTruthy();
expect(content).toContain(`<text:p text:style-name="${name}">two`);
});
});