test: 完成 DOCX 全主题视觉验收
This commit is contained in:
@@ -176,6 +176,9 @@ describe("动态 reference.docx", () => {
|
||||
expect(stylesXml).toContain('w:eastAsia="Microsoft YaHei"');
|
||||
expect(footerXml).toContain(" PAGE \\* MERGEFORMAT ");
|
||||
expect(footerXml).toContain(" NUMPAGES \\* MERGEFORMAT ");
|
||||
expect(footerXml).toContain('w:jc w:val="center"');
|
||||
expect(footerXml).toContain('w:before="0"');
|
||||
expect(footerXml).not.toContain("<w:tbl");
|
||||
expect(validateDynamicReferenceDocx(first.content)).toMatchObject({
|
||||
partCount: first.partCount,
|
||||
headerCount: 0,
|
||||
@@ -237,6 +240,16 @@ describe("动态 reference.docx", () => {
|
||||
expect(settingsXml).toContain("<w:evenAndOddHeaders");
|
||||
expect(headerXml).toContain("年度 <报告>");
|
||||
expect(headerXml).toContain("报告 & 计划.md");
|
||||
expect(headerXml).toContain('w:tab w:val="center"');
|
||||
expect(headerXml).toContain('w:tab w:val="right"');
|
||||
expect(headerXml).toContain('w:pos="6860"');
|
||||
expect(headerXml).toContain('w:pos="13720"');
|
||||
expect(headerXml).toContain("<w:pBdr>");
|
||||
expect(headerXml).toContain("<w:bottom");
|
||||
expect(headerXml).not.toContain("<w:tbl");
|
||||
expect(
|
||||
decoder.decode(entries["word/footer1.xml"])
|
||||
).not.toContain("<w:tbl");
|
||||
expect(relationships.match(/relationships\/header/gu)).toHaveLength(
|
||||
3
|
||||
);
|
||||
@@ -275,6 +288,28 @@ describe("动态 reference.docx", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("拒绝使用表格模拟页眉页脚布局", () => {
|
||||
const result = createDynamicReferenceDocx(
|
||||
createBaselineReference(),
|
||||
createOptions(defaultExportConfig)
|
||||
);
|
||||
const entries = new Map(
|
||||
Object.entries(unzipSync(result.content))
|
||||
);
|
||||
const footer = decoder
|
||||
.decode(entries.get("word/footer1.xml")!)
|
||||
.replace(
|
||||
"</w:ftr>",
|
||||
"<w:tbl><w:tr><w:tc><w:p/></w:tc></w:tr></w:tbl></w:ftr>"
|
||||
);
|
||||
entries.set("word/footer1.xml", encoder.encode(footer));
|
||||
const damaged = writeReferenceDocxPackage(entries);
|
||||
|
||||
expect(() => validateDynamicReferenceDocx(damaged)).toThrow(
|
||||
/不得使用表格模拟页眉页脚布局/u
|
||||
);
|
||||
});
|
||||
|
||||
it("最终 DOCX 使用媒体输出上限而非模板的 2 MiB 上限", () => {
|
||||
const result = createDynamicReferenceDocx(
|
||||
createBaselineReference(),
|
||||
|
||||
Reference in New Issue
Block a user