import React from "react";
import { assert } from "chai";
import loadEL from "../../node/el/loadEL";
import type * as std from "../../law/std";
import { DOCXRemarks, HTMLRemarks } from "./remarks";
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 remarks", () => {
/* eslint-disable no-irregular-whitespace */
it("Success case", async () => {
const input = loadEL({
tag: "Remarks",
attr: {},
children: [
{
tag: "RemarksLabel",
attr: {},
children: ["備考"],
},
{
tag: "Sentence",
attr: {},
children: ["路程の計算については、水路及び陸路四分の一キロメートルをもつて鉄道一キロメートルとみなす。"],
},
],
}) as std.Remarks;
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.remarks.html");
await promisify(fs.writeFile)(tempParsedHtml, html);
console.log(` Saved html: ${tempParsedHtml}`);
});
});
describe("Test DOCX remarks", () => {
/* eslint-disable no-irregular-whitespace */
it("Success case", async () => {
const input = loadEL({
tag: "Remarks",
attr: {},
children: [
{
tag: "RemarksLabel",
attr: {},
children: ["備考"],
},
{
tag: "Sentence",
attr: {},
children: ["路程の計算については、水路及び陸路四分の一キロメートルをもつて鉄道一キロメートルとみなす。"],
},
],
}) as std.Remarks;
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.remarks.docx");
fs.writeFileSync(tempParsedDocx, u8);
console.log(` Saved docx: ${tempParsedDocx}`);
});
});