Skip to content

Commit

Permalink
Clean up and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanmiu committed Apr 10, 2018
1 parent ecf1542 commit 41f9417
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/file/paragraph/paragraph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/file/paragraph/paragraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 41f9417

Please sign in to comment.