2024-10-21 03:57:15 +01:00
|
|
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
2023-03-15 02:46:39 +00:00
|
|
|
|
import { IViewWrapper } from "@file/document-wrapper";
|
|
|
|
|
import { File } from "@file/file";
|
2023-03-16 01:55:18 +00:00
|
|
|
|
import { Paragraph, TextRun } from "@file/paragraph";
|
2023-03-15 02:46:39 +00:00
|
|
|
|
import { IContext } from "@file/xml-components";
|
|
|
|
|
|
|
|
|
|
import { PatchType } from "./from-docx";
|
|
|
|
|
import { replacer } from "./replacer";
|
|
|
|
|
|
2023-12-31 23:16:48 +00:00
|
|
|
|
export const MOCK_JSON = {
|
2023-03-15 02:46:39 +00:00
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:hdr",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:p",
|
|
|
|
|
attributes: { "w14:paraId": "3BE1A671", "w14:textId": "74E856C4", "w:rsidR": "000D38A7", "w:rsidRDefault": "000D38A7" },
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:pPr",
|
|
|
|
|
elements: [{ type: "element", name: "w:pStyle", attributes: { "w:val": "Header" } }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [{ type: "element", name: "w:t", elements: [{ type: "text", text: "This is a {{head" }] }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
attributes: { "w:rsidR": "004A3A99" },
|
|
|
|
|
elements: [{ type: "element", name: "w:t", elements: [{ type: "text", text: "er" }] }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "element", name: "w:t", elements: [{ type: "text", text: "_adjective}} don’t you think?" }] },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2023-10-18 12:58:01 -03:00
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:p",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [{ type: "element", name: "w:b", attributes: { "w:val": "1" } }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "What a {{bold}} text!" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2023-03-15 02:46:39 +00:00
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
describe("replacer", () => {
|
|
|
|
|
describe("replacer", () => {
|
2023-12-31 23:16:48 +00:00
|
|
|
|
it("should throw an error if nothing is added", () => {
|
|
|
|
|
expect(() =>
|
|
|
|
|
replacer({
|
|
|
|
|
json: {
|
|
|
|
|
elements: [],
|
|
|
|
|
},
|
|
|
|
|
patch: {
|
|
|
|
|
type: PatchType.PARAGRAPH,
|
|
|
|
|
children: [],
|
|
|
|
|
},
|
|
|
|
|
patchText: "hello",
|
|
|
|
|
// eslint-disable-next-line functional/prefer-readonly-type
|
|
|
|
|
context: vi.fn<[], IContext>()(),
|
|
|
|
|
}),
|
|
|
|
|
).toThrow();
|
2023-03-15 02:46:39 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-03-16 01:55:18 +00:00
|
|
|
|
it("should replace paragraph type", () => {
|
2023-12-31 23:16:48 +00:00
|
|
|
|
const output = replacer({
|
|
|
|
|
json: JSON.parse(JSON.stringify(MOCK_JSON)),
|
|
|
|
|
patch: {
|
2023-03-15 02:46:39 +00:00
|
|
|
|
type: PatchType.PARAGRAPH,
|
|
|
|
|
children: [new TextRun("Delightful Header")],
|
|
|
|
|
},
|
2023-12-31 23:16:48 +00:00
|
|
|
|
patchText: "{{header_adjective}}",
|
|
|
|
|
context: {
|
2023-03-15 02:46:39 +00:00
|
|
|
|
file: {} as unknown as File,
|
|
|
|
|
viewWrapper: {
|
|
|
|
|
Relationships: {},
|
|
|
|
|
} as unknown as IViewWrapper,
|
|
|
|
|
stack: [],
|
|
|
|
|
},
|
2023-12-31 23:16:48 +00:00
|
|
|
|
});
|
2023-03-15 02:46:39 +00:00
|
|
|
|
|
|
|
|
|
expect(JSON.stringify(output)).to.contain("Delightful Header");
|
|
|
|
|
});
|
2023-03-16 01:55:18 +00:00
|
|
|
|
|
2023-10-18 12:58:01 -03:00
|
|
|
|
it("should replace paragraph type keeping original styling if keepOriginalStyles is true", () => {
|
2023-12-31 23:16:48 +00:00
|
|
|
|
const output = replacer({
|
|
|
|
|
json: JSON.parse(JSON.stringify(MOCK_JSON)),
|
|
|
|
|
patch: {
|
2023-10-18 12:58:01 -03:00
|
|
|
|
type: PatchType.PARAGRAPH,
|
|
|
|
|
children: [new TextRun("sweet")],
|
|
|
|
|
},
|
2023-12-31 23:16:48 +00:00
|
|
|
|
patchText: "{{bold}}",
|
|
|
|
|
context: {
|
2023-10-18 12:58:01 -03:00
|
|
|
|
file: {} as unknown as File,
|
|
|
|
|
viewWrapper: {
|
|
|
|
|
Relationships: {},
|
|
|
|
|
} as unknown as IViewWrapper,
|
|
|
|
|
stack: [],
|
|
|
|
|
},
|
2023-12-31 23:16:48 +00:00
|
|
|
|
keepOriginalStyles: true,
|
|
|
|
|
});
|
2023-10-18 12:58:01 -03:00
|
|
|
|
|
|
|
|
|
expect(JSON.stringify(output)).to.contain("sweet");
|
|
|
|
|
expect(output.elements![0].elements![1].elements).toMatchObject([
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [{ type: "element", name: "w:b", attributes: { "w:val": "1" } }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "What a " }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [{ type: "element", name: "w:b", attributes: { "w:val": "1" } }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "sweet" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [{ type: "element", name: "w:b", attributes: { "w:val": "1" } }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: " text!" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-16 01:55:18 +00:00
|
|
|
|
it("should replace document type", () => {
|
2023-12-31 23:16:48 +00:00
|
|
|
|
const output = replacer({
|
|
|
|
|
json: JSON.parse(JSON.stringify(MOCK_JSON)),
|
|
|
|
|
patch: {
|
2023-03-16 01:55:18 +00:00
|
|
|
|
type: PatchType.DOCUMENT,
|
|
|
|
|
children: [new Paragraph("Lorem ipsum paragraph")],
|
|
|
|
|
},
|
2023-12-31 23:16:48 +00:00
|
|
|
|
patchText: "{{header_adjective}}",
|
|
|
|
|
context: {
|
2023-03-16 01:55:18 +00:00
|
|
|
|
file: {} as unknown as File,
|
|
|
|
|
viewWrapper: {
|
|
|
|
|
Relationships: {},
|
|
|
|
|
} as unknown as IViewWrapper,
|
|
|
|
|
stack: [],
|
|
|
|
|
},
|
2023-12-31 23:16:48 +00:00
|
|
|
|
});
|
2023-03-16 01:55:18 +00:00
|
|
|
|
|
|
|
|
|
expect(JSON.stringify(output)).to.contain("Lorem ipsum paragraph");
|
|
|
|
|
});
|
2024-10-13 01:29:32 +01:00
|
|
|
|
|
|
|
|
|
it("should replace", () => {
|
|
|
|
|
// cspell:disable
|
|
|
|
|
const output = replacer({
|
|
|
|
|
json: {
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:hdr",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:p",
|
|
|
|
|
elements: [
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "{{" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "s" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "chool_" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "n" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "{{" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "a" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "ddr" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "ess" }],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:r",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rPr",
|
|
|
|
|
elements: [
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:rFonts",
|
|
|
|
|
attributes: { "w:eastAsia": "Times New Roman" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:kern",
|
|
|
|
|
attributes: { "w:val": "0" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:sz",
|
|
|
|
|
attributes: { "w:val": "20" },
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:lang",
|
|
|
|
|
attributes: {
|
|
|
|
|
"w:val": "en-US",
|
|
|
|
|
"w:eastAsia": "en-US",
|
|
|
|
|
"w:bidi": "ar-SA",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ type: "text", text: "\n " },
|
|
|
|
|
{
|
|
|
|
|
type: "element",
|
|
|
|
|
name: "w:t",
|
|
|
|
|
elements: [{ type: "text", text: "}}" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
// cspell:enable
|
|
|
|
|
patch: {
|
|
|
|
|
type: PatchType.PARAGRAPH,
|
|
|
|
|
children: [new Paragraph("Lorem ipsum paragraph")],
|
|
|
|
|
},
|
|
|
|
|
patchText: "{{address}}",
|
|
|
|
|
context: {
|
|
|
|
|
file: {} as unknown as File,
|
|
|
|
|
viewWrapper: {
|
|
|
|
|
Relationships: {},
|
|
|
|
|
} as unknown as IViewWrapper,
|
|
|
|
|
stack: [],
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(JSON.stringify(output)).to.contain("Lorem ipsum paragraph");
|
|
|
|
|
});
|
2023-03-15 02:46:39 +00:00
|
|
|
|
});
|
|
|
|
|
});
|