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

8
.nycrc
View File

@ -1,9 +1,9 @@
{
"check-coverage": true,
"lines": 98.31,
"functions": 95.83,
"branches": 95.38,
"statements": 98.29,
"lines": 98.47,
"functions": 96.44,
"branches": 95.39,
"statements": 98.45,
"include": [
"src/**/*.ts"
],

View File

@ -1,11 +1,9 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IAppPropertiesAttributes {
export class AppPropertiesAttributes extends XmlAttributeComponent<{
readonly xmlns: string;
readonly vt: string;
}
export class AppPropertiesAttributes extends XmlAttributeComponent<IAppPropertiesAttributes> {
}> {
protected readonly xmlKeys = {
xmlns: "xmlns",
vt: "xmlns:vt",

View File

@ -1,10 +1,8 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IContentTypeAttributes {
export class ContentTypeAttributes extends XmlAttributeComponent<{
readonly xmlns?: string;
}
export class ContentTypeAttributes extends XmlAttributeComponent<IContentTypeAttributes> {
}> {
protected readonly xmlKeys = {
xmlns: "xmlns",
};

View File

@ -1,11 +1,9 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IDefaultAttributes {
export class DefaultAttributes extends XmlAttributeComponent<{
readonly contentType: string;
readonly extension?: string;
}
export class DefaultAttributes extends XmlAttributeComponent<IDefaultAttributes> {
}> {
protected readonly xmlKeys = {
contentType: "ContentType",
extension: "Extension",

View File

@ -1,11 +1,9 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IOverrideAttributes {
export class OverrideAttributes extends XmlAttributeComponent<{
readonly contentType: string;
readonly partName?: string;
}
export class OverrideAttributes extends XmlAttributeComponent<IOverrideAttributes> {
}> {
protected readonly xmlKeys = {
contentType: "ContentType",
partName: "PartName",

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);
}
}
}