added bullet

This commit is contained in:
Dolan Miu
2016-03-30 02:55:11 +01:00
parent 099da3d90c
commit b749e42671
7 changed files with 106 additions and 15 deletions

View File

@ -99,4 +99,18 @@ describe('Paragraph', () => {
assert(newJson.p[1].pPr[1].r[0].br[0]._attrs.type === "page");
});
});
describe("#bullet()", () => {
it("should add list paragraph style to JSON", () => {
paragraph.bullet();
var newJson = jsonify(paragraph);
assert(newJson.p[1].pPr[1].pStyle[0]._attrs.val === "ListParagraph");
});
it("it should add numbered properties", () => {
paragraph.bullet();
var newJson = jsonify(paragraph);
assert.isDefined(newJson.p[1].pPr[2].numPr);
});
});
});

28
ts/tests/styleTest.ts Normal file
View File

@ -0,0 +1,28 @@
/// <reference path="../typings/mocha/mocha.d.ts" />
/// <reference path="../typings/chai/chai.d.ts" />
import {Style} from "../docx/paragraph/style";
import {assert} from "chai";
function jsonify(obj: Object) {
var stringifiedJson = JSON.stringify(obj);
return JSON.parse(stringifiedJson);
}
describe("Style", () => {
var style: Style;
describe("#constructor()", () => {
it("should create a style with given value", () => {
style = new Style("test");
var newJson = jsonify(style);
assert(newJson.pStyle[0]._attrs.val === "test");
});
it("should create a style with blank val", () => {
style = new Style("");
var newJson = jsonify(style);
assert(newJson.pStyle[0]._attrs.val === "");
});
});
});