TOC content generation aborted

This commit is contained in:
Sergio Mendonça
2018-09-21 11:16:14 -03:00
parent 8b463b3bb6
commit 4ca81df401
9 changed files with 14 additions and 165 deletions

View File

@ -393,43 +393,4 @@ describe("Paragraph", () => {
});
});
});
describe("#clone", () => {
it("changes in a cloned paragraph must not affect the original paragraph", () => {
paragraph.pageBreakBefore();
const tree = new Formatter().format(paragraph);
expect(tree).to.deep.equal({ "w:p": [{ "w:pPr": [{ "w:pageBreakBefore": [] }] }] }, "Paragraph with a page break before");
const clonedParagraph = paragraph.clone();
expect(clonedParagraph).to.be.instanceof(file.Paragraph);
expect(clonedParagraph.paragraphProperties).to.be.instanceof(file.ParagraphProperties);
const clonedTree = new Formatter().format(clonedParagraph);
expect(clonedTree).to.deep.equal(
{
"w:p": [{ "w:pPr": [{ "w:pageBreakBefore": [] }] }],
},
"Cloned Paragraph with page break before",
);
clonedParagraph.clearPageBreaks();
const clonedTreeAfter = new Formatter().format(clonedParagraph);
expect(clonedTreeAfter).to.deep.equal(
{
"w:p": [{ "w:pPr": [] }],
},
"Cloned Paragraph after clearPageBreaks must have no properties",
);
const treeAfter = new Formatter().format(paragraph);
expect(treeAfter).to.deep.equal(
{
"w:p": [{ "w:pPr": [{ "w:pageBreakBefore": [] }] }],
},
"Paragraph after clearPageBreaks in Cloned Paragraph must keep the properties.",
);
});
});
});

View File

@ -1,6 +1,4 @@
// http://officeopenxml.com/WPparagraph.php
import * as cloneDeep from "lodash.clonedeep";
import { FootnoteReferenceRun } from "file/footnotes/footnote/run/reference-run";
import { Image } from "file/media";
import { Num } from "file/numbering/num";
@ -252,8 +250,4 @@ export class Paragraph extends XmlComponent {
this.properties.clearPageBreaks();
return this;
}
public clone(): Paragraph {
return cloneDeep(this, false);
}
}