import React from "react"; import { assert } from "chai"; import loadEL from "../../node/el/loadEL"; import type * as std from "../../law/std"; import { DOCXParagraphItem, HTMLParagraphItem } from "./paragraphItem"; import { renderToStaticMarkup } from "../common"; import { renderDocxAsync } from "../common/docx/file"; import ensureTempTestDir from "../../../test/ensureTempTestDir"; import path from "path"; import fs from "fs"; import formatXML from "../../util/formatXml"; import htmlCSS from "./htmlCSS"; import { promisify } from "util"; describe("Test HTML paragraphItem", () => { /* eslint-disable no-irregular-whitespace */ it("Success case", async () => { const input = loadEL({ tag: "Item", attr: { }, children: [ { tag: "ItemTitle", attr: {}, children: ["一"], }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Column", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["法令"], }, ], }, { tag: "Column", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["法律、法律に基づく命令(告示を含む。)、条例及び地方公共団体の執行機関の規則(規程を含む。以下「規則」という。)をいう。"], }, ], }, ], }, ], }) as std.Item; const expectedHTML = /*html*/`\
  法令   法律、法律に基づく命令(告示を含む。)、条例及び地方公共団体の執行機関の規則(規程を含む。以下「規則」という。)をいう。
`; const element = ; const rendered = renderToStaticMarkup(element); const formatted = formatXML(rendered, { collapseContent: true }); assert.strictEqual( formatted, expectedHTML, ); const html = /*html*/`\ ${rendered} `; const tempParsedHtml = path.join(ensureTempTestDir(), "renderer.paragraphItem.html"); await promisify(fs.writeFile)(tempParsedHtml, html); console.log(` Saved html: ${tempParsedHtml}`); }); }); describe("Test DOCX paragraphItem", () => { /* eslint-disable no-irregular-whitespace */ it("Success case", async () => { const input = loadEL({ tag: "Item", attr: { }, children: [ { tag: "ItemTitle", attr: {}, children: ["一"], }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Column", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["法令"], }, ], }, { tag: "Column", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["法律、法律に基づく命令(告示を含む。)、条例及び地方公共団体の執行機関の規則(規程を含む。以下「規則」という。)をいう。"], }, ], }, ], }, ], }) as std.Item; const expectedDOCX = /*xml*/`\   法令   法律、法律に基づく命令(告示を含む。)、条例及び地方公共団体の執行機関の規則(規程を含む。以下「規則」という。)をいう。 `; const element = ; const rendered = renderToStaticMarkup(element); const formatted = formatXML(rendered, { collapseContent: true }); assert.strictEqual( formatted, expectedDOCX, ); const u8 = await renderDocxAsync(element); const tempParsedDocx = path.join(ensureTempTestDir(), "renderer.paragraphItem.docx"); fs.writeFileSync(tempParsedDocx, u8); console.log(` Saved docx: ${tempParsedDocx}`); }); });