Clean up and tests

This commit is contained in:
Dolan
2018-04-10 21:54:52 +01:00
parent ecf1542d95
commit 41f941728e
2 changed files with 17 additions and 2 deletions

View File

@ -162,6 +162,22 @@ describe("Paragraph", () => {
});
describe("#bullet()", () => {
it("should default to 0 indent level if no bullet was specified", () => {
paragraph.bullet();
const tree = new Formatter().format(paragraph);
expect(tree)
.to.have.property("w:p")
.which.is.an("array")
.which.has.length.at.least(1);
expect(tree["w:p"][0])
.to.have.property("w:pPr")
.which.is.an("array")
.which.has.length.at.least(1);
expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({
"w:pStyle": [{ _attr: { "w:val": "ListParagraph" } }],
});
});
it("should add list paragraph style to JSON", () => {
paragraph.bullet(0);
const tree = new Formatter().format(paragraph);

View File

@ -129,8 +129,7 @@ export class Paragraph extends XmlComponent {
return this;
}
public bullet(indentLevel: number): Paragraph {
indentLevel = indentLevel || 0;
public bullet(indentLevel: number = 0): Paragraph {
this.properties.push(new Style("ListParagraph"));
this.properties.push(new NumberProperties(1, indentLevel));
return this;