made all tests passing
This commit is contained in:
@ -14,6 +14,7 @@ export class Body implements XmlComponent {
|
||||
}
|
||||
|
||||
push(component: XmlComponent) {
|
||||
this.body.splice(this.body.length - 1, 0, component);
|
||||
//this.body.splice(this.body.length - 1, 0, component);
|
||||
this.body.push(component);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
import {XmlComponent} from "../../docx/xml-components";
|
||||
|
||||
export class Name implements XmlComponent {
|
||||
private name: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.name = new Array<XmlComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
export class BasedOn {
|
||||
|
||||
}
|
||||
|
||||
export class Next {
|
||||
|
||||
}
|
||||
|
||||
export class Link {
|
||||
|
||||
}
|
||||
|
||||
export class UiPriority {
|
||||
|
||||
}
|
||||
|
||||
export class UnhideWhenUsed {
|
||||
|
||||
}
|
||||
|
||||
export class QFormat {
|
||||
|
||||
}
|
||||
|
||||
export class TableProperties {
|
||||
|
||||
}
|
||||
|
||||
export class RsId {
|
||||
|
||||
}
|
||||
|
||||
export class SemiHidden {
|
||||
|
||||
}
|
@ -16,7 +16,7 @@ describe("Attribute", () => {
|
||||
var newAttrs = new Attributes();
|
||||
var stringifiedJson = JSON.stringify(newAttrs);
|
||||
var newJson = JSON.parse(stringifiedJson);
|
||||
assert.isUndefined(newJson._attrs.val);
|
||||
assert.isUndefined(newJson._attr.val);
|
||||
});
|
||||
|
||||
it("should have val as defined with populated constructor", () => {
|
||||
@ -25,7 +25,7 @@ describe("Attribute", () => {
|
||||
});
|
||||
var stringifiedJson = JSON.stringify(newAttrs);
|
||||
var newJson = JSON.parse(stringifiedJson);
|
||||
assert(newJson._attrs.val === "test");
|
||||
assert(newJson._attr.val === "test");
|
||||
});
|
||||
|
||||
it("should have space value as defined with populated constructor", () => {
|
||||
@ -34,7 +34,7 @@ describe("Attribute", () => {
|
||||
});
|
||||
var stringifiedJson = JSON.stringify(newAttrs);
|
||||
var newJson = JSON.parse(stringifiedJson);
|
||||
assert(newJson._attrs.space === "spaceTest");
|
||||
assert(newJson._attr.space === "spaceTest");
|
||||
});
|
||||
});
|
||||
});
|
@ -2,6 +2,11 @@
|
||||
/// <reference path="../typings/chai/chai.d.ts" />
|
||||
import {Body} from "../docx/document/body";
|
||||
import {assert} from "chai";
|
||||
import {SectionProperties} from "../docx/document/body/section-properties";
|
||||
import {PageSize} from "../docx/document/body/page-size";
|
||||
import {PageMargin} from "../docx/document/body/page-margin";
|
||||
import {Columns} from "../docx/document/body/columns";
|
||||
import {DocumentGrid} from "../docx/document/body/doc-grid";
|
||||
|
||||
function jsonify(obj: Object) {
|
||||
var stringifiedJson = JSON.stringify(obj);
|
||||
@ -13,12 +18,18 @@ describe("Body", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
body = new Body();
|
||||
body.push(new SectionProperties());
|
||||
body.push(new PageSize());
|
||||
body.push(new PageMargin());
|
||||
body.push(new Columns());
|
||||
body.push(new DocumentGrid());
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
|
||||
it("should create the Section Properties", () => {
|
||||
var newJson = jsonify(body);
|
||||
console.log(newJson);
|
||||
assert.isDefined(newJson.body[0].sectPr);
|
||||
});
|
||||
|
||||
|
@ -28,8 +28,8 @@ describe("ThematicBreak", () => {
|
||||
val: "single",
|
||||
sz: "6"
|
||||
};
|
||||
delete newJson.pBdr[0].bottom[0]._attrs.xmlKeys;
|
||||
assert(JSON.stringify(newJson.pBdr[0].bottom[0]._attrs) === JSON.stringify(attributes));
|
||||
delete newJson.pBdr[0].bottom[0]._attr.xmlKeys;
|
||||
assert(JSON.stringify(newJson.pBdr[0].bottom[0]._attr) === JSON.stringify(attributes));
|
||||
});
|
||||
})
|
||||
});
|
@ -41,7 +41,7 @@ describe("Formatter", () => {
|
||||
paragraph.addText(new docx.TextRun("test").bold());
|
||||
var newJson = formatter.format(paragraph);
|
||||
newJson = jsonify(newJson);
|
||||
assert.isDefined(newJson["w:p"][3]["w:r"][0]["w:rPr"][0]["w:b"][0]["_attrs"]["w:val"]);
|
||||
assert.isDefined(newJson["w:p"][3]["w:r"][0]["w:rPr"][0]["w:b"][0]["_attr"]["w:val"]);
|
||||
});
|
||||
|
||||
it("should format attributes (rsidSect)", () => {
|
||||
@ -50,7 +50,7 @@ describe("Formatter", () => {
|
||||
});
|
||||
var newJson = formatter.format(attributes);
|
||||
newJson = jsonify(newJson);
|
||||
assert.isDefined(newJson["_attrs"]["w:rsidSect"]);
|
||||
assert.isDefined(newJson["_attr"]["w:rsidSect"]);
|
||||
});
|
||||
|
||||
it("should format attributes (val)", () => {
|
||||
@ -59,7 +59,7 @@ describe("Formatter", () => {
|
||||
});
|
||||
var newJson = formatter.format(attributes);
|
||||
newJson = jsonify(newJson);
|
||||
assert.isDefined(newJson["_attrs"]["w:val"]);
|
||||
assert.isDefined(newJson["_attr"]["w:val"]);
|
||||
});
|
||||
|
||||
it("should should change 'p' tag into 'w:p' tag", () => {
|
||||
|
@ -29,7 +29,7 @@ describe("Packer", () => {
|
||||
|
||||
it("should create a standard docx file", (done) => {
|
||||
packer.pack();
|
||||
setTimeout(done, 3000);
|
||||
setTimeout(done, 1900);
|
||||
});
|
||||
});
|
||||
});
|
@ -8,20 +8,20 @@ function jsonify(obj: Object) {
|
||||
return JSON.parse(stringifiedJson);
|
||||
}
|
||||
|
||||
describe("Style", () => {
|
||||
describe("ParagraphStyle", () => {
|
||||
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");
|
||||
assert(newJson.pStyle[0]._attr.val === "test");
|
||||
});
|
||||
|
||||
it("should create a style with blank val", () => {
|
||||
style = new Style("");
|
||||
var newJson = jsonify(style);
|
||||
assert(newJson.pStyle[0]._attrs.val === "");
|
||||
assert(newJson.pStyle[0]._attr.val === "");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -35,7 +35,7 @@ describe("Paragraph", () => {
|
||||
paragraph.heading1();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attrs.val === "Heading1");
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Heading1");
|
||||
});
|
||||
});
|
||||
|
||||
@ -44,7 +44,7 @@ describe("Paragraph", () => {
|
||||
paragraph.heading2();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attrs.val === "Heading2");
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Heading2");
|
||||
});
|
||||
});
|
||||
|
||||
@ -53,7 +53,7 @@ describe("Paragraph", () => {
|
||||
paragraph.heading3();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attrs.val === "Heading3");
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Heading3");
|
||||
});
|
||||
});
|
||||
|
||||
@ -62,7 +62,7 @@ describe("Paragraph", () => {
|
||||
paragraph.title();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attrs.val === "Title");
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "Title");
|
||||
});
|
||||
});
|
||||
|
||||
@ -71,7 +71,7 @@ describe("Paragraph", () => {
|
||||
paragraph.center();
|
||||
var newJson = jsonify(paragraph);
|
||||
|
||||
assert(newJson.p[1].pPr[1].jc[0]._attrs.val === "center");
|
||||
assert(newJson.p[1].pPr[1].jc[0]._attr.val === "center");
|
||||
});
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@ describe("Paragraph", () => {
|
||||
it("should add page break with 'page' type", () => {
|
||||
paragraph.pageBreak();
|
||||
var newJson = jsonify(paragraph);
|
||||
assert(newJson.p[1].pPr[1].r[1].br[0]._attrs.type === "page");
|
||||
assert(newJson.p[1].pPr[1].r[1].br[0]._attr.type === "page");
|
||||
});
|
||||
});
|
||||
|
||||
@ -102,7 +102,7 @@ describe("Paragraph", () => {
|
||||
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");
|
||||
assert(newJson.p[1].pPr[1].pStyle[0]._attr.val === "ListParagraph");
|
||||
});
|
||||
|
||||
it("it should add numbered properties", () => {
|
||||
|
Reference in New Issue
Block a user