Write tests
This commit is contained in:
8
.nycrc
8
.nycrc
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"check-coverage": true,
|
"check-coverage": true,
|
||||||
"lines": 98.31,
|
"lines": 98.47,
|
||||||
"functions": 95.83,
|
"functions": 96.44,
|
||||||
"branches": 95.38,
|
"branches": 95.39,
|
||||||
"statements": 98.29,
|
"statements": 98.45,
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts"
|
"src/**/*.ts"
|
||||||
],
|
],
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import { XmlAttributeComponent } from "file/xml-components";
|
import { XmlAttributeComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IAppPropertiesAttributes {
|
export class AppPropertiesAttributes extends XmlAttributeComponent<{
|
||||||
readonly xmlns: string;
|
readonly xmlns: string;
|
||||||
readonly vt: string;
|
readonly vt: string;
|
||||||
}
|
}> {
|
||||||
|
|
||||||
export class AppPropertiesAttributes extends XmlAttributeComponent<IAppPropertiesAttributes> {
|
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
xmlns: "xmlns",
|
xmlns: "xmlns",
|
||||||
vt: "xmlns:vt",
|
vt: "xmlns:vt",
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import { XmlAttributeComponent } from "file/xml-components";
|
import { XmlAttributeComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IContentTypeAttributes {
|
export class ContentTypeAttributes extends XmlAttributeComponent<{
|
||||||
readonly xmlns?: string;
|
readonly xmlns?: string;
|
||||||
}
|
}> {
|
||||||
|
|
||||||
export class ContentTypeAttributes extends XmlAttributeComponent<IContentTypeAttributes> {
|
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
xmlns: "xmlns",
|
xmlns: "xmlns",
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import { XmlAttributeComponent } from "file/xml-components";
|
import { XmlAttributeComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IDefaultAttributes {
|
export class DefaultAttributes extends XmlAttributeComponent<{
|
||||||
readonly contentType: string;
|
readonly contentType: string;
|
||||||
readonly extension?: string;
|
readonly extension?: string;
|
||||||
}
|
}> {
|
||||||
|
|
||||||
export class DefaultAttributes extends XmlAttributeComponent<IDefaultAttributes> {
|
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
contentType: "ContentType",
|
contentType: "ContentType",
|
||||||
extension: "Extension",
|
extension: "Extension",
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import { XmlAttributeComponent } from "file/xml-components";
|
import { XmlAttributeComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IOverrideAttributes {
|
export class OverrideAttributes extends XmlAttributeComponent<{
|
||||||
readonly contentType: string;
|
readonly contentType: string;
|
||||||
readonly partName?: string;
|
readonly partName?: string;
|
||||||
}
|
}> {
|
||||||
|
|
||||||
export class OverrideAttributes extends XmlAttributeComponent<IOverrideAttributes> {
|
|
||||||
protected readonly xmlKeys = {
|
protected readonly xmlKeys = {
|
||||||
contentType: "ContentType",
|
contentType: "ContentType",
|
||||||
partName: "PartName",
|
partName: "PartName",
|
||||||
|
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";
|
export * from "./latent-styles";
|
||||||
import { LatentStyleException } from "./exceptions";
|
|
||||||
|
|
||||||
export class LatentStyles extends XmlComponent {
|
|
||||||
constructor() {
|
|
||||||
super("w:latentStyles");
|
|
||||||
}
|
|
||||||
|
|
||||||
public push(latentException: LatentStyleException): void {
|
|
||||||
this.root.push(latentException);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
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