Write tests

This commit is contained in:
Dolan
2021-03-13 22:10:00 +00:00
parent 4bc0421055
commit 0bc36d924f
9 changed files with 91 additions and 32 deletions

View File

@ -0,0 +1,32 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { LatentStyleException } from "./exceptions";
describe("LatentStyleException", () => {
describe("#constructor()", () => {
it("should create", () => {
const currentLatentStyleException = new LatentStyleException({
name: "test-name",
uiPriority: "test-uiPriority",
qFormat: "test-qFormat",
semiHidden: "test-semiHidden",
unhideWhenUsed: "test-unhideWhenUsed",
});
const tree = new Formatter().format(currentLatentStyleException);
expect(tree).to.deep.equal({
"w:lsdException": {
_attr: {
"w:name": "test-name",
"w:qFormat": "test-qFormat",
"w:semiHidden": "test-semiHidden",
"w:uiPriority": "test-uiPriority",
"w:unhideWhenUsed": "test-unhideWhenUsed",
},
},
});
});
});
});

View File

@ -1,12 +1 @@
import { XmlComponent } from "file/xml-components";
import { LatentStyleException } from "./exceptions";
export class LatentStyles extends XmlComponent {
constructor() {
super("w:latentStyles");
}
public push(latentException: LatentStyleException): void {
this.root.push(latentException);
}
}
export * from "./latent-styles";

View File

@ -0,0 +1,34 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { LatentStyleException } from "./exceptions";
import { LatentStyles } from "./latent-styles";
describe("LatentStyles", () => {
describe("#constructor()", () => {
it("should create", () => {
const currentLatentStyles = new LatentStyles();
const tree = new Formatter().format(currentLatentStyles);
expect(tree).to.deep.equal({
"w:latentStyles": {},
});
});
it("should create with exception", () => {
const currentLatentStyles = new LatentStyles(new LatentStyleException({}));
const tree = new Formatter().format(currentLatentStyles);
expect(tree).to.deep.equal({
"w:latentStyles": [
{
"w:lsdException": {
_attr: {},
},
},
],
});
});
});
});

View File

@ -0,0 +1,12 @@
import { XmlComponent } from "file/xml-components";
import { LatentStyleException } from "./exceptions";
export class LatentStyles extends XmlComponent {
constructor(latentException?: LatentStyleException) {
super("w:latentStyles");
if (latentException) {
this.root.push(latentException);
}
}
}