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