2017-03-07 22:15:53 +00:00
|
|
|
import { Attributes } from "../../../docx/xml-components";
|
|
|
|
import { assert } from "chai";
|
2016-03-29 04:10:33 +01:00
|
|
|
|
2016-04-03 05:24:56 +01:00
|
|
|
describe("Attribute", () => {
|
2016-05-26 15:08:34 +01:00
|
|
|
let attributes: Attributes;
|
2016-03-29 04:10:33 +01:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
attributes = new Attributes();
|
|
|
|
});
|
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("#constructor()", () => {
|
2016-03-29 04:10:33 +01:00
|
|
|
|
|
|
|
it("should not add val with empty constructor", () => {
|
2016-05-26 15:08:34 +01:00
|
|
|
let newAttrs = new Attributes();
|
|
|
|
let stringifiedJson = JSON.stringify(newAttrs);
|
|
|
|
let newJson = JSON.parse(stringifiedJson);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.isUndefined(newJson.root.val);
|
2016-03-29 04:10:33 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should have val as defined with populated constructor", () => {
|
2016-05-26 15:08:34 +01:00
|
|
|
let newAttrs = new Attributes({
|
2016-03-29 04:50:23 +01:00
|
|
|
val: "test"
|
|
|
|
});
|
2016-05-26 15:08:34 +01:00
|
|
|
let stringifiedJson = JSON.stringify(newAttrs);
|
|
|
|
let newJson = JSON.parse(stringifiedJson);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root.val, "test");
|
2016-03-29 04:10:33 +01:00
|
|
|
});
|
2016-03-30 03:50:53 +01:00
|
|
|
|
|
|
|
it("should have space value as defined with populated constructor", () => {
|
2016-05-26 15:08:34 +01:00
|
|
|
let newAttrs = new Attributes({
|
2016-03-30 03:50:53 +01:00
|
|
|
space: "spaceTest"
|
|
|
|
});
|
2016-05-26 15:08:34 +01:00
|
|
|
let stringifiedJson = JSON.stringify(newAttrs);
|
|
|
|
let newJson = JSON.parse(stringifiedJson);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root.space, "spaceTest");
|
2016-03-30 03:50:53 +01:00
|
|
|
});
|
2016-03-29 04:10:33 +01:00
|
|
|
});
|
|
|
|
});
|