Files
docx-js/ts/tests/docx/xml-components/attributeTest.ts
2017-03-09 22:56:08 +00:00

39 lines
1.3 KiB
TypeScript

import { assert } from "chai";
import { Attributes } from "../../../docx/xml-components";
describe("Attribute", () => {
let attributes: Attributes;
beforeEach(() => {
attributes = new Attributes();
});
describe("#constructor()", () => {
it("should not add val with empty constructor", () => {
const newAttrs = new Attributes();
const stringifiedJson = JSON.stringify(newAttrs);
const newJson = JSON.parse(stringifiedJson);
assert.isUndefined(newJson.root.val);
});
it("should have val as defined with populated constructor", () => {
const newAttrs = new Attributes({
val: "test",
});
const stringifiedJson = JSON.stringify(newAttrs);
const newJson = JSON.parse(stringifiedJson);
assert.equal(newJson.root.val, "test");
});
it("should have space value as defined with populated constructor", () => {
const newAttrs = new Attributes({
space: "spaceTest",
});
const stringifiedJson = JSON.stringify(newAttrs);
const newJson = JSON.parse(stringifiedJson);
assert.equal(newJson.root.space, "spaceTest");
});
});
});