import React from "react";
import { assert } from "chai";
import loadEL from "../../node/el/loadEL";
import type * as std from "../../law/std";
import { DOCXArticleGroup, HTMLArticleGroup } from "./articleGroup";
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 articleGroup", () => {
/* eslint-disable no-irregular-whitespace */
it("Success case", async () => {
const input = loadEL({
tag: "Chapter",
attr: { Num: "3",
},
children: [
{
tag: "ChapterTitle",
attr: {},
children: ["第三章 不利益処分"],
},
{
tag: "Section",
attr: { Num: "1",
},
children: [
{
tag: "SectionTitle",
attr: {},
children: ["第一節 通則"],
},
{
tag: "Article",
attr: {},
children: [
{
tag: "ArticleCaption",
attr: {},
children: ["(処分の基準)"],
},
{
tag: "ArticleTitle",
attr: {},
children: ["第十二条"],
},
{
tag: "Paragraph",
attr: {},
children: [
{
tag: "ParagraphNum",
attr: {},
children: [],
},
{
tag: "ParagraphSentence",
attr: {},
children: [
{
tag: "Sentence",
attr: {},
children: ["行政庁は、処分基準を定め、かつ、これを公にしておくよう努めなければならない。"],
},
],
},
],
},
],
},
],
},
{
tag: "Section",
attr: { Num: "2",
},
children: [
{
tag: "SectionTitle",
attr: {},
children: ["第二節 聴聞"],
},
{
tag: "Article",
attr: {},
children: [
{
tag: "ArticleCaption",
attr: {},
children: ["(聴聞の通知の方式)"],
},
{
tag: "ArticleTitle",
attr: {},
children: ["第十五条"],
},
{
tag: "Paragraph",
attr: {},
children: [
{
tag: "ParagraphNum",
attr: {},
children: [],
},
{
tag: "ParagraphSentence",
attr: {},
children: [
{
tag: "Sentence",
attr: {},
children: ["行政庁は、聴聞を行うに当たっては、聴聞を行うべき期日までに相当な期間をおいて、不利益処分の名あて人となるべき者に対し、次に掲げる事項を書面により通知しなければならない。"],
},
],
},
],
},
],
},
],
},
],
}) as std.ArticleGroup;
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.articleGroup.html");
await promisify(fs.writeFile)(tempParsedHtml, html);
console.log(` Saved html: ${tempParsedHtml}`);
});
});
describe("Test DOCX articleGroup", () => {
/* eslint-disable no-irregular-whitespace */
it("Success case", async () => {
const input = loadEL({
tag: "Chapter",
attr: { Num: "3",
},
children: [
{
tag: "ChapterTitle",
attr: {},
children: ["第三章 不利益処分"],
},
{
tag: "Section",
attr: { Num: "1",
},
children: [
{
tag: "SectionTitle",
attr: {},
children: ["第一節 通則"],
},
{
tag: "Article",
attr: {},
children: [
{
tag: "ArticleCaption",
attr: {},
children: ["(処分の基準)"],
},
{
tag: "ArticleTitle",
attr: {},
children: ["第十二条"],
},
{
tag: "Paragraph",
attr: {},
children: [
{
tag: "ParagraphNum",
attr: {},
children: [],
},
{
tag: "ParagraphSentence",
attr: {},
children: [
{
tag: "Sentence",
attr: {},
children: ["行政庁は、処分基準を定め、かつ、これを公にしておくよう努めなければならない。"],
},
],
},
],
},
],
},
],
},
{
tag: "Section",
attr: { Num: "2",
},
children: [
{
tag: "SectionTitle",
attr: {},
children: ["第二節 聴聞"],
},
{
tag: "Article",
attr: {},
children: [
{
tag: "ArticleCaption",
attr: {},
children: ["(聴聞の通知の方式)"],
},
{
tag: "ArticleTitle",
attr: {},
children: ["第十五条"],
},
{
tag: "Paragraph",
attr: {},
children: [
{
tag: "ParagraphNum",
attr: {},
children: [],
},
{
tag: "ParagraphSentence",
attr: {},
children: [
{
tag: "Sentence",
attr: {},
children: ["行政庁は、聴聞を行うに当たっては、聴聞を行うべき期日までに相当な期間をおいて、不利益処分の名あて人となるべき者に対し、次に掲げる事項を書面により通知しなければならない。"],
},
],
},
],
},
],
},
],
},
],
}) as std.ArticleGroup;
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.articleGroup.docx");
fs.writeFileSync(tempParsedDocx, u8);
console.log(` Saved docx: ${tempParsedDocx}`);
});
});