// OOXML toggles are ST_OnOff: the element being present does not mean "on", since // w:val="false"/"0"/"off" turns it off. Word and the docx lib both write the explicit // false form. jsdom (vitest `environment`) supplies the global DOMParser. import { describe, it, expect } from 'vitest'; import { zipSync, strToU8 } from 'fflate'; import { importDocx } from '../../src/lib/import/docx'; const CT = ` `; const RELS = ` `; const DOC_RELS = ` `; const W = 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"'; const HEADER = `Running head`; const DOCUMENT = ` Body `; const settings = (val: string) => ``; const build = (settingsXml: string) => zipSync({ '[Content_Types].xml': strToU8(CT), '_rels/.rels': strToU8(RELS), 'word/_rels/document.xml.rels': strToU8(DOC_RELS), 'word/document.xml': strToU8(DOCUMENT), 'word/header1.xml': strToU8(HEADER), 'word/settings.xml': strToU8(settingsXml), }); describe('DOCX on/off toggles', () => { it('reads an explicit false as off', () => { const r = importDocx(build(settings('false'))); expect(r.header).not.toBeNull(); // Both off, so the one header repeats on every page instead of odd/even variants. expect(r.differentOddEven).toBe(false); expect(r.differentFirstPage).toBe(false); }); it('still reads a bare element as on', () => { const r = importDocx(build(``)); expect(r.differentOddEven).toBe(true); }); });