fixing tests
This commit is contained in:
@ -36,12 +36,11 @@ describe("Formatter", () => {
|
||||
assert(stringifiedJson.indexOf("xmlKeys") < 0);
|
||||
});
|
||||
|
||||
it.only("should format simple paragraph with bold text", () => {
|
||||
it("should format simple paragraph with bold text", () => {
|
||||
var paragraph = new docx.Paragraph();
|
||||
paragraph.addText(new docx.TextRun("test").bold());
|
||||
var newJson = formatter.format(paragraph);
|
||||
newJson = jsonify(newJson);
|
||||
console.log(JSON.stringify(newJson, null, " "));
|
||||
assert.isDefined(newJson["w:p"][1]["w:r"][0]["w:rPr"][0]["w:b"][0]["_attr"]["w:val"]);
|
||||
});
|
||||
|
||||
|
@ -25,7 +25,7 @@ describe("Packer", () => {
|
||||
packer = new LocalPacker(document, DefaultStyle(), properties, "build/tests/test.docx");
|
||||
});
|
||||
|
||||
describe('#pack()', () => {
|
||||
describe.only('#pack()', () => {
|
||||
|
||||
it("should create a standard docx file", (done) => {
|
||||
packer.pack();
|
||||
|
@ -15,13 +15,14 @@ describe("ParagraphStyle", () => {
|
||||
it("should create a style with given value", () => {
|
||||
style = new Style("test");
|
||||
var newJson = jsonify(style);
|
||||
assert(newJson.pStyle[0]._attr.val === "test");
|
||||
console.log(newJson.root[0].root.val);
|
||||
assert.equal(newJson.root[0].root.val, "test");
|
||||
});
|
||||
|
||||
it("should create a style with blank val", () => {
|
||||
style = new Style("");
|
||||
var newJson = jsonify(style);
|
||||
assert(newJson.pStyle[0]._attr.val === "");
|
||||
assert.equal(newJson.root[0].root.val, "");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -34,8 +34,7 @@ describe("Paragraph", () => {
|
||||
it("should add heading style to JSON", () => {
|
||||
paragraph.heading1();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.root[1].root[1].root[0]._attr.val === "Heading1");
|
||||
assert.equal(newJson.root[0].root[1].root[0].root.val, "Heading1");
|
||||
});
|
||||
});
|
||||
|
||||
@ -44,7 +43,7 @@ describe("Paragraph", () => {
|
||||
paragraph.heading2();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Heading2");
|
||||
assert.equal(newJson.root[0].root[1].root[0].root.val, "Heading2");
|
||||
});
|
||||
});
|
||||
|
||||
@ -53,7 +52,7 @@ describe("Paragraph", () => {
|
||||
paragraph.heading3();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Heading3");
|
||||
assert.equal(newJson.root[0].root[1].root[0].root.val, "Heading3");
|
||||
});
|
||||
});
|
||||
|
||||
@ -62,7 +61,7 @@ describe("Paragraph", () => {
|
||||
paragraph.title();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Title");
|
||||
assert.equal(newJson.root[0].root[1].root[0].root.val, "Title");
|
||||
});
|
||||
});
|
||||
|
||||
@ -71,7 +70,7 @@ describe("Paragraph", () => {
|
||||
paragraph.center();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].jc[0]._attr.val === "center");
|
||||
assert.equal(newJson.root[0].root[1].root[0].root.val, "center");
|
||||
});
|
||||
});
|
||||
|
||||
@ -79,8 +78,7 @@ describe("Paragraph", () => {
|
||||
it("should add thematic break to JSON", () => {
|
||||
paragraph.thematicBreak();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert.isDefined(newJson.p[1].pPr[1].pBdr);
|
||||
assert.equal(newJson.root[0].root[1].rootKey, "w:pBdr");
|
||||
});
|
||||
});
|
||||
|
||||
@ -88,13 +86,13 @@ describe("Paragraph", () => {
|
||||
it("should add page break to JSON", () => {
|
||||
paragraph.pageBreak();
|
||||
var newJson = jsonify(paragraph);
|
||||
assert.isDefined(newJson.p[1].pPr[1].r[1].br);
|
||||
assert.equal(newJson.root[0].root[1].root[1].rootKey, "w:br");
|
||||
});
|
||||
|
||||
it("should add page break with 'page' type", () => {
|
||||
paragraph.pageBreak();
|
||||
var newJson = jsonify(paragraph);
|
||||
assert(newJson.p[1].pPr[1].r[1].br[0]._attr.type === "page");
|
||||
assert.equal(newJson.root[0].root[1].root[1].root[0].root.type, "page");
|
||||
});
|
||||
});
|
||||
|
||||
@ -102,13 +100,13 @@ describe("Paragraph", () => {
|
||||
it("should add list paragraph style to JSON", () => {
|
||||
paragraph.bullet();
|
||||
var newJson = jsonify(paragraph);
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "ListParagraph");
|
||||
assert.equal(newJson.root[0].root[1].root[0].root.val, "ListParagraph");
|
||||
});
|
||||
|
||||
it("it should add numbered properties", () => {
|
||||
paragraph.bullet();
|
||||
var newJson = jsonify(paragraph);
|
||||
assert.isDefined(newJson.p[1].pPr[2].numPr);
|
||||
assert.isDefined(newJson.root[0].root[2]);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user