2016-03-29 04:10:33 +01:00
|
|
|
/// <reference path="../typings/mocha/mocha.d.ts" />
|
|
|
|
/// <reference path="../typings/chai/chai.d.ts" />
|
2016-03-29 04:50:23 +01:00
|
|
|
import {Attributes} from "../docx/xml-components";
|
2016-03-29 04:10:33 +01:00
|
|
|
import {assert} from "chai";
|
|
|
|
|
2016-04-03 05:24:56 +01:00
|
|
|
describe("Attribute", () => {
|
2016-03-29 04:10:33 +01:00
|
|
|
var attributes: Attributes;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
attributes = new Attributes();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('#constructor()', () => {
|
|
|
|
|
|
|
|
it("should not add val with empty constructor", () => {
|
|
|
|
var newAttrs = new Attributes();
|
|
|
|
var stringifiedJson = JSON.stringify(newAttrs);
|
|
|
|
var 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-03-29 04:50:23 +01:00
|
|
|
var newAttrs = new Attributes({
|
|
|
|
val: "test"
|
|
|
|
});
|
2016-03-29 04:10:33 +01:00
|
|
|
var stringifiedJson = JSON.stringify(newAttrs);
|
|
|
|
var 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", () => {
|
|
|
|
var newAttrs = new Attributes({
|
|
|
|
space: "spaceTest"
|
|
|
|
});
|
|
|
|
var stringifiedJson = JSON.stringify(newAttrs);
|
|
|
|
var 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
|
|
|
});
|
|
|
|
});
|