Skip to content

Commit

Permalink
Merge pull request #190 from dolanmiu/feat/more-tests
Browse files Browse the repository at this point in the history
Introduce some functional programming techniques
  • Loading branch information
dolanmiu authored Nov 2, 2018
2 parents 40d6a41 + 1813451 commit 401ef73
Show file tree
Hide file tree
Showing 108 changed files with 749 additions and 659 deletions.
8 changes: 4 additions & 4 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"check-coverage": true,
"lines": 87.39,
"functions": 83.54,
"branches": 71.95,
"statements": 87.17,
"lines": 87.54,
"functions": 83.61,
"branches": 72.57,
"statements": 87.32,
"include": [
"src/**/*.ts"
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"sinon": "^5.0.7",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-immutable": "^4.9.0",
"typedoc": "^0.11.1",
"typescript": "2.9.2",
"webpack": "^3.10.0"
Expand Down
32 changes: 16 additions & 16 deletions src/export/packer/next-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import { File } from "file";
import { Formatter } from "../formatter";

interface IXmlifyedFile {
data: string;
path: string;
readonly data: string;
readonly path: string;
}

interface IXmlifyedFileMapping {
Document: IXmlifyedFile;
Styles: IXmlifyedFile;
Properties: IXmlifyedFile;
Numbering: IXmlifyedFile;
Relationships: IXmlifyedFile;
FileRelationships: IXmlifyedFile;
Headers: IXmlifyedFile[];
Footers: IXmlifyedFile[];
HeaderRelationships: IXmlifyedFile[];
FooterRelationships: IXmlifyedFile[];
ContentTypes: IXmlifyedFile;
AppProperties: IXmlifyedFile;
FootNotes: IXmlifyedFile;
Settings: IXmlifyedFile;
readonly Document: IXmlifyedFile;
readonly Styles: IXmlifyedFile;
readonly Properties: IXmlifyedFile;
readonly Numbering: IXmlifyedFile;
readonly Relationships: IXmlifyedFile;
readonly FileRelationships: IXmlifyedFile;
readonly Headers: IXmlifyedFile[];
readonly Footers: IXmlifyedFile[];
readonly HeaderRelationships: IXmlifyedFile[];
readonly FooterRelationships: IXmlifyedFile[];
readonly ContentTypes: IXmlifyedFile;
readonly AppProperties: IXmlifyedFile;
readonly FootNotes: IXmlifyedFile;
readonly Settings: IXmlifyedFile;
}

export class Compiler {
Expand Down
6 changes: 3 additions & 3 deletions src/file/app-properties/app-properties-attributes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IAppPropertiesAttributes {
xmlns: string;
vt: string;
readonly xmlns: string;
readonly vt: string;
}

export class AppPropertiesAttributes extends XmlAttributeComponent<IAppPropertiesAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
xmlns: "xmlns",
vt: "xmlns:vt",
};
Expand Down
4 changes: 2 additions & 2 deletions src/file/content-types/content-types-attributes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IContentTypeAttributes {
xmlns?: string;
readonly xmlns?: string;
}

export class ContentTypeAttributes extends XmlAttributeComponent<IContentTypeAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
xmlns: "xmlns",
};
}
6 changes: 3 additions & 3 deletions src/file/content-types/default/default-attributes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IDefaultAttributes {
contentType: string;
extension?: string;
readonly contentType: string;
readonly extension?: string;
}

export class DefaultAttributes extends XmlAttributeComponent<IDefaultAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
contentType: "ContentType",
extension: "Extension",
};
Expand Down
6 changes: 3 additions & 3 deletions src/file/content-types/override/override-attributes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IOverrideAttributes {
contentType: string;
partName?: string;
readonly contentType: string;
readonly partName?: string;
}

export class OverrideAttributes extends XmlAttributeComponent<IOverrideAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
contentType: "ContentType",
partName: "PartName",
};
Expand Down
16 changes: 8 additions & 8 deletions src/file/core-properties/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { DocumentAttributes } from "../document/document-attributes";
import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components";

export interface IPropertiesOptions {
title?: string;
subject?: string;
creator?: string;
keywords?: string;
description?: string;
lastModifiedBy?: string;
revision?: string;
externalStyles?: string;
readonly title?: string;
readonly subject?: string;
readonly creator?: string;
readonly keywords?: string;
readonly description?: string;
readonly lastModifiedBy?: string;
readonly revision?: string;
readonly externalStyles?: string;
}

export class CoreProperties extends XmlComponent {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IColumnsAttributes {
space?: number;
readonly space?: number;
}

export class ColumnsAttributes extends XmlAttributeComponent<IColumnsAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
space: "w:space",
};
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IDocGridAttributesProperties {
linePitch?: number;
readonly linePitch?: number;
}

export class DocGridAttributes extends XmlAttributeComponent<IDocGridAttributesProperties> {
protected xmlKeys = {
protected readonly xmlKeys = {
linePitch: "w:linePitch",
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export enum FooterReferenceType {
}

export interface IFooterReferenceAttributes {
type: string;
id: string;
readonly type: string;
readonly id: string;
}

export class FooterReferenceAttributes extends XmlAttributeComponent<IFooterReferenceAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
type: "w:type",
id: "r:id",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { XmlComponent } from "file/xml-components";
import { FooterReferenceAttributes, FooterReferenceType } from "./footer-reference-attributes";

export interface IFooterOptions {
footerType?: FooterReferenceType;
footerId?: number;
readonly footerType?: FooterReferenceType;
readonly footerId?: number;
}

export class FooterReference extends XmlComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export enum HeaderReferenceType {
}

export interface IHeaderReferenceAttributes {
type: string;
id: string;
readonly type: string;
readonly id: string;
}

export class HeaderReferenceAttributes extends XmlAttributeComponent<IHeaderReferenceAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
type: "w:type",
id: "r:id",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { XmlComponent } from "file/xml-components";
import { HeaderReferenceAttributes, HeaderReferenceType } from "./header-reference-attributes";

export interface IHeaderOptions {
headerType?: HeaderReferenceType;
headerId?: number;
readonly headerType?: HeaderReferenceType;
readonly headerId?: number;
}

export class HeaderReference extends XmlComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ export enum PageBorderZOrder {
}

export interface IPageBorderAttributes {
display?: PageBorderDisplay;
offsetFrom?: PageBorderOffsetFrom;
zOrder?: PageBorderZOrder;
readonly display?: PageBorderDisplay;
readonly offsetFrom?: PageBorderOffsetFrom;
readonly zOrder?: PageBorderZOrder;
}

export interface IPageBorderConfiguration {
style?: BorderStyle;
size?: number;
color?: string;
space?: number;
readonly style?: BorderStyle;
readonly size?: number;
readonly color?: string;
readonly space?: number;
}

export interface IPageBordersOptions {
pageBorders?: IPageBorderAttributes;
pageBorderTop?: IPageBorderConfiguration;
pageBorderRight?: IPageBorderConfiguration;
pageBorderBottom?: IPageBorderConfiguration;
pageBorderLeft?: IPageBorderConfiguration;
readonly pageBorders?: IPageBorderAttributes;
readonly pageBorderTop?: IPageBorderConfiguration;
readonly pageBorderRight?: IPageBorderConfiguration;
readonly pageBorderBottom?: IPageBorderConfiguration;
readonly pageBorderLeft?: IPageBorderConfiguration;
}

class PageBordeAttributes extends XmlAttributeComponent<IPageBorderConfiguration> {
protected xmlKeys = {
protected readonly xmlKeys = {
style: "w:val",
size: "w:size",
color: "w:color",
Expand All @@ -57,7 +57,7 @@ class PageBorder extends XmlComponent {
}

class PageBordersAttributes extends XmlAttributeComponent<IPageBorderAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
display: "w:display",
offsetFrom: "w:offsetFrom",
zOrder: "w:zOrder",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IPageMarginAttributes {
top?: number;
right?: number;
bottom?: number;
left?: number;
header?: number;
footer?: number;
gutter?: number;
mirror?: boolean;
readonly top?: number;
readonly right?: number;
readonly bottom?: number;
readonly left?: number;
readonly header?: number;
readonly footer?: number;
readonly gutter?: number;
readonly mirror?: boolean;
}

export class PageMarginAttributes extends XmlAttributeComponent<IPageMarginAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
top: "w:top",
right: "w:right",
bottom: "w:bottom",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export enum PageNumberFormat {
}

export interface IPageNumberTypeAttributes {
pageNumberStart?: number;
pageNumberFormatType?: PageNumberFormat;
readonly pageNumberStart?: number;
readonly pageNumberFormatType?: PageNumberFormat;
}

export class PageNumberTypeAttributes extends XmlAttributeComponent<IPageNumberTypeAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
pageNumberStart: "w:start",
pageNumberFormatType: "w:fmt",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export enum PageOrientation {
}

export interface IPageSizeAttributes {
width?: number;
height?: number;
orientation?: PageOrientation;
readonly width?: number;
readonly height?: number;
readonly orientation?: PageOrientation;
}

export class PageSizeAttributes extends XmlAttributeComponent<IPageSizeAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
width: "w:w",
height: "w:h",
orientation: "w:orient",
Expand Down
12 changes: 6 additions & 6 deletions src/file/document/body/section-properties/section-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ import { IPageSizeAttributes, PageOrientation } from "./page-size/page-size-attr
import { TitlePage } from "./title-page/title-page";

export interface IHeaderFooterGroup<T> {
default?: T;
first?: T;
even?: T;
readonly default?: T;
readonly first?: T;
readonly even?: T;
}

interface IHeadersOptions {
headers?: IHeaderFooterGroup<HeaderWrapper>;
readonly headers?: IHeaderFooterGroup<HeaderWrapper>;
}

interface IFootersOptions {
footers?: IHeaderFooterGroup<FooterWrapper>;
readonly footers?: IHeaderFooterGroup<FooterWrapper>;
}

interface ITitlePageOptions {
titlePage?: boolean;
readonly titlePage?: boolean;
}

export type SectionPropertiesOptions = IPageSizeAttributes &
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";

export interface IHeaderReferenceAttributes {
value: string;
readonly value: string;
}

export class TitlePageAttributes extends XmlAttributeComponent<IHeaderReferenceAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
value: "w:val",
};
}
Loading

0 comments on commit 401ef73

Please sign in to comment.