Files
docx-js/src/patcher/paragraph-token-replacer.spec.ts

75 lines
2.5 KiB
TypeScript
Raw Normal View History

2023-03-15 02:46:39 +00:00
import { expect } from "chai";
import { replaceTokenInParagraphElement } from "./paragraph-token-replacer";
describe("paragraph-token-replacer", () => {
describe("replaceTokenInParagraphElement", () => {
it("should replace token in paragraph", () => {
const output = replaceTokenInParagraphElement({
paragraphElement: {
name: "w:p",
elements: [
{
name: "w:r",
elements: [
{
name: "w:t",
elements: [
{
type: "text",
text: "hello",
},
],
},
],
},
],
},
renderedParagraph: {
index: 0,
path: [0],
runs: [
{
end: 4,
index: 0,
parts: [
{
end: 4,
index: 0,
start: 0,
text: "hello",
},
],
start: 0,
text: "hello",
},
],
text: "hello",
},
originalText: "hello",
replacementText: "world",
});
expect(output).to.deep.equal({
elements: [
{
elements: [
{
elements: [
{
text: "world",
type: "text",
},
],
name: "w:t",
},
],
name: "w:r",
},
],
name: "w:p",
});
});
});
});