This change brings increased type safety to uses of XmlAttributeComponent. Now the compiler is checkign for us that the properties that get passed in to every subclass match the intended interface, and also that the xmlKeys property -> xml attribute mapping has all the right keys
26 lines
896 B
TypeScript
26 lines
896 B
TypeScript
import { assert } from "chai";
|
|
import { Attributes } from "../../../docx/xml-components";
|
|
|
|
describe("Attribute", () => {
|
|
describe("#constructor()", () => {
|
|
|
|
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");
|
|
});
|
|
});
|
|
});
|