Write tests
This commit is contained in:
32
src/file/styles/latent-styles/exceptions.spec.ts
Normal file
32
src/file/styles/latent-styles/exceptions.spec.ts
Normal 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",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -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";
|
||||
|
34
src/file/styles/latent-styles/latent-styles.spec.ts
Normal file
34
src/file/styles/latent-styles/latent-styles.spec.ts
Normal 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: {},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
12
src/file/styles/latent-styles/latent-styles.ts
Normal file
12
src/file/styles/latent-styles/latent-styles.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user