From a2284df8817c0a46b5d9feae6076f027967a89f3 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Thu, 26 May 2016 15:08:34 +0100 Subject: [PATCH] fixed all tslint errors --- ts/docx/document/body/index.ts | 4 +- ts/docx/document/document-attributes.ts | 4 +- ts/docx/document/index.ts | 4 +- ts/docx/paragraph/border.ts | 2 +- ts/docx/paragraph/index.ts | 4 +- ts/docx/paragraph/unordered-list.ts | 2 +- ts/docx/run/formatting.ts | 6 +-- ts/docx/run/index.ts | 6 +-- ts/docx/xml-components/default-attributes.ts | 4 +- ts/docx/xml-components/index.ts | 4 +- ts/docx/xml-components/property.ts | 4 +- ts/export/formatter.ts | 10 ++-- ts/export/packer/express.ts | 12 ++--- ts/export/packer/local.ts | 18 +++---- ts/export/packer/packer.ts | 38 +++++++-------- ts/numbering/abstract-numbering.ts | 10 ++-- ts/numbering/indent.ts | 8 ++-- ts/numbering/index.ts | 48 +++++++++---------- ts/numbering/level.ts | 4 +- ts/numbering/multi-level-type.ts | 2 +- ts/numbering/num.ts | 8 ++-- ts/numbering/run-fonts.ts | 10 ++-- ts/properties/components.ts | 18 +++---- ts/styles/defaults/index.ts | 6 +-- ts/styles/defaults/run-properties.ts | 2 +- ts/styles/factory.ts | 26 +++++----- ts/styles/index.ts | 16 +++---- .../latent-styles/exceptions/attributes.ts | 10 ++-- ts/styles/latent-styles/index.ts | 4 +- ts/styles/style/components.ts | 2 +- ts/styles/style/index.ts | 4 +- ts/tests/attributeTest.ts | 22 ++++----- ts/tests/bodyTest.ts | 14 +++--- ts/tests/borderTest.ts | 10 ++-- ts/tests/documentTest.ts | 11 ++--- ts/tests/formatterTest.ts | 36 +++++++------- ts/tests/localPackerTest.ts | 26 +++++----- ts/tests/paragraphStyleTest.ts | 8 ++-- ts/tests/paragraphTest.ts | 34 ++++++------- ts/tests/propertiesTest.ts | 8 ++-- ts/tests/runTest.ts | 26 +++++----- ts/tests/stylesTest.ts | 12 ++--- 42 files changed, 253 insertions(+), 254 deletions(-) diff --git a/ts/docx/document/body/index.ts b/ts/docx/document/body/index.ts index bca20ebdc2..8e29a5056f 100644 --- a/ts/docx/document/body/index.ts +++ b/ts/docx/document/body/index.ts @@ -5,11 +5,11 @@ export class Body extends XmlComponent { constructor() { super("w:body"); - //this.root.push(new SectionProperties()); not actually needed + // this.root.push(new SectionProperties()); not actually needed } push(component: XmlComponent) { - //this.root.splice(this.body.length - 1, 0, component); + // this.root.splice(this.body.length - 1, 0, component); this.root.push(component); } } diff --git a/ts/docx/document/document-attributes.ts b/ts/docx/document/document-attributes.ts index fede6c2ed3..a23be1d38d 100644 --- a/ts/docx/document/document-attributes.ts +++ b/ts/docx/document/document-attributes.ts @@ -54,8 +54,8 @@ export class DocumentAttributes extends XmlAttributeComponent { xsi: "xmlns:xsi", type: "xsi:type" }, properties); - - this.root = properties + + this.root = properties; if (!properties) { this.root = {}; diff --git a/ts/docx/document/index.ts b/ts/docx/document/index.ts index 2006c12d63..c7fc59ea45 100644 --- a/ts/docx/document/index.ts +++ b/ts/docx/document/index.ts @@ -1,5 +1,5 @@ import {XmlComponent} from "../xml-components"; -import {DocumentAttributes} from "./document-attributes" +import {DocumentAttributes} from "./document-attributes"; import {Body} from "./body"; import {Paragraph} from "../paragraph"; @@ -34,7 +34,7 @@ export class Document extends XmlComponent { addParagraph(paragraph: Paragraph): void { this.body.push(paragraph); } - + clearVariables(): void { this.body.clearVariables(); delete this.body; diff --git a/ts/docx/paragraph/border.ts b/ts/docx/paragraph/border.ts index 79f96b078b..ac4d8f77da 100644 --- a/ts/docx/paragraph/border.ts +++ b/ts/docx/paragraph/border.ts @@ -14,7 +14,7 @@ class Border extends XmlComponent { } export class ThematicBreak extends XmlComponent { - + constructor() { super("w:pBdr"); this.root.push(new Border()); diff --git a/ts/docx/paragraph/index.ts b/ts/docx/paragraph/index.ts index 4a30ba4b00..064226f0e6 100644 --- a/ts/docx/paragraph/index.ts +++ b/ts/docx/paragraph/index.ts @@ -98,9 +98,9 @@ export class Paragraph extends XmlComponent { this.properties.push(new MaxRightTabStop()); return this; } - + leftTabStop(position: number): Paragraph { - this.properties.push(new LeftTabStop(position)) + this.properties.push(new LeftTabStop(position)); return this; } diff --git a/ts/docx/paragraph/unordered-list.ts b/ts/docx/paragraph/unordered-list.ts index b6d1e52a8f..a3116214cf 100644 --- a/ts/docx/paragraph/unordered-list.ts +++ b/ts/docx/paragraph/unordered-list.ts @@ -2,7 +2,7 @@ import {XmlComponent, Attributes} from "../xml-components"; import {Style} from "./style"; export class NumberProperties extends XmlComponent { - + constructor() { super("w:numPr"); this.root.push(new IndentLevel(0)); diff --git a/ts/docx/run/formatting.ts b/ts/docx/run/formatting.ts index 09a8cec201..c274e69739 100644 --- a/ts/docx/run/formatting.ts +++ b/ts/docx/run/formatting.ts @@ -1,7 +1,7 @@ import {XmlComponent, Attributes} from "../xml-components"; export class Bold extends XmlComponent { - + constructor() { super("w:b"); this.root.push(new Attributes({ @@ -20,7 +20,7 @@ export class Italics extends XmlComponent { } } -// needs work. add more types of underline +// TODO needs work. add more types of underline export class Underline extends XmlComponent { constructor() { @@ -121,7 +121,7 @@ export class Size extends XmlComponent { } } -// needs work. Add more types of vertical align +// TODO needs work. Add more types of vertical align export class VerticalAlign extends XmlComponent { constructor() { diff --git a/ts/docx/run/index.ts b/ts/docx/run/index.ts index e503108fa9..7081ccb979 100644 --- a/ts/docx/run/index.ts +++ b/ts/docx/run/index.ts @@ -4,7 +4,7 @@ import {Bold, Italics, Underline} from "./formatting"; export class Run extends XmlComponent { private properties: RunProperties; - + constructor() { super("w:r"); @@ -26,12 +26,12 @@ export class Run extends XmlComponent { this.properties.push(new Underline()); return this; } - + break(): Run { // TODO return this; } - + tab(): Run { // TODO return this; diff --git a/ts/docx/xml-components/default-attributes.ts b/ts/docx/xml-components/default-attributes.ts index 4834502de5..977db58a63 100644 --- a/ts/docx/xml-components/default-attributes.ts +++ b/ts/docx/xml-components/default-attributes.ts @@ -9,7 +9,7 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent { super("_attr"); this.xmlKeys = xmlKeys; - this.root = properties + this.root = properties; if (!properties) { this.root = {}; @@ -19,7 +19,7 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent { replaceKey(): void { if (this.root !== undefined) { _.forOwn(this.root, (value, key) => { - var newKey = this.xmlKeys[key]; + let newKey = this.xmlKeys[key]; this.root[newKey] = value; delete this.root[key]; }); diff --git a/ts/docx/xml-components/index.ts b/ts/docx/xml-components/index.ts index 283638fe75..fe73e6dcfe 100644 --- a/ts/docx/xml-components/index.ts +++ b/ts/docx/xml-components/index.ts @@ -10,8 +10,8 @@ export abstract class XmlComponent extends BaseXmlComponent { } replaceKey(): void { - //console.log(this.rootKey); - //console.log(this.root); + // console.log(this.rootKey); + // console.log(this.root); if (this.root !== undefined) { this.root.forEach(root => { if (root && root instanceof BaseXmlComponent) { diff --git a/ts/docx/xml-components/property.ts b/ts/docx/xml-components/property.ts index fdb6087900..9c4790c87d 100644 --- a/ts/docx/xml-components/property.ts +++ b/ts/docx/xml-components/property.ts @@ -1,4 +1,4 @@ -import {XmlComponent} from "./" +import {XmlComponent} from "./"; import {ParagraphProperties} from "../paragraph/properties"; import {RunProperties} from "../run/properties"; @@ -42,7 +42,7 @@ export class MultiPropertyXmlComponent extends XmlComponent { super(rootKey); this.runProperties = new RunProperties(); this.root.push(this.runProperties); - + this.paragraphProperties = new ParagraphProperties(); this.root.push(this.paragraphProperties); } diff --git a/ts/export/formatter.ts b/ts/export/formatter.ts index b9fc323bd7..d8a79b8e9c 100644 --- a/ts/export/formatter.ts +++ b/ts/export/formatter.ts @@ -6,8 +6,8 @@ export class Formatter { format(input: any): Object { input.clearVariables(); this.replaceKeys(input); - var newJson = this.clense(input); - //console.log(JSON.stringify(newJson, null, " ")); + let newJson = this.clense(input); + // console.log(JSON.stringify(newJson, null, " ")); return newJson; } @@ -18,7 +18,7 @@ export class Formatter { } private clense(input: any): Object { - var newJson = this.jsonify(input); + let newJson = this.jsonify(input); this.deepTraverseJson(newJson, (parent, value, key) => { if (key === "properties") { @@ -36,13 +36,13 @@ export class Formatter { } private jsonify(obj: Object): Object { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } private deepTraverseJson(json: Object, lambda: (json: any, value: any, key: any) => void): void { _.forOwn(json, (value, key) => { - if (_.isObject(value) && key !== "xmlKeys" && key != "rootKey") { + if (_.isObject(value) && key !== "xmlKeys" && key !== "rootKey") { this.deepTraverseJson(value, lambda); } lambda(json, value, key); diff --git a/ts/export/packer/express.ts b/ts/export/packer/express.ts index 3db8dd852a..8dc941c124 100644 --- a/ts/export/packer/express.ts +++ b/ts/export/packer/express.ts @@ -3,7 +3,7 @@ import * as fs from "fs"; import * as express from "express"; import {Document} from "../../docx/document"; import {Properties} from "../../properties"; -import {DefaultStylesFactory} from "../../styles/factory" +import {DefaultStylesFactory} from "../../styles/factory"; import {Numbering} from "../../numbering"; export class ExpressPacker extends Packer { @@ -11,8 +11,8 @@ export class ExpressPacker extends Packer { constructor(document: Document, res: express.Response, styles?: any, properties?: Properties, numbering?: Numbering) { if (!styles) { - var stylesFactory = new DefaultStylesFactory(); - styles = stylesFactory.newInstance() + let stylesFactory = new DefaultStylesFactory(); + styles = stylesFactory.newInstance(); } if (!properties) { @@ -22,7 +22,7 @@ export class ExpressPacker extends Packer { lastModifiedBy: "Shan Fu" }); } - + if (!numbering) { numbering = new Numbering(); } @@ -30,8 +30,8 @@ export class ExpressPacker extends Packer { super(document, styles, properties, numbering); this.res = res; - this.res.on('close', () => { - return res.status(200).send('OK').end(); + this.res.on("close", () => { + return res.status(200).send("OK").end(); }); } diff --git a/ts/export/packer/local.ts b/ts/export/packer/local.ts index fccab59afa..513d474310 100644 --- a/ts/export/packer/local.ts +++ b/ts/export/packer/local.ts @@ -1,23 +1,23 @@ import {Packer} from "./packer"; -import * as fs from 'fs'; +import * as fs from "fs"; import {Document} from "../../docx/document"; import {Properties} from "../../properties"; import {Numbering} from "../../numbering"; export class LocalPacker extends Packer { - private stream: fs.WriteStream - + private stream: fs.WriteStream; + constructor(document: Document, style: any, properties: Properties, path: string, numbering?: Numbering) { - + if (!numbering) { numbering = new Numbering(); } - + super(document, style, properties, numbering); this.stream = fs.createWriteStream(path); } - - pack(): void { - super.pack(this.stream); - } + + pack(): void { + super.pack(this.stream); + } } \ No newline at end of file diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts index 8b24d2c199..6b06e7cda2 100644 --- a/ts/export/packer/packer.ts +++ b/ts/export/packer/packer.ts @@ -7,7 +7,7 @@ import {Styles} from "../../styles"; import {Properties} from "../../properties"; import {Numbering} from "../../numbering"; -var appRoot = require('app-root-path'); +let appRoot = require("app-root-path"); export abstract class Packer { protected archive: any; @@ -16,7 +16,7 @@ export abstract class Packer { private style: Styles; private properties: Properties; private numbering: Numbering; - + constructor(document: Document, style: any, properties: Properties, numbering: Numbering) { this.formatter = new Formatter(); this.document = document; @@ -25,7 +25,7 @@ export abstract class Packer { this.numbering = numbering; this.archive = archiver.create("zip", {}); - this.archive.on('error', (err) => { + this.archive.on("error", (err) => { throw err; }); } @@ -37,39 +37,39 @@ export abstract class Packer { { expand: true, cwd: appRoot.path + "/template", - src: ['**', '**/.rels'] + src: ["**", "**/.rels"] } ]); - //this.archive.file(appRoot.path + "/template/[Content_Types].xml", { name: "[Content_Types].xml" }); - //console.log(__dirname + "/packer.js"); - //this.archive.file(__dirname + "/packer.js", { name: "/[Content_Types].xml" }); + // this.archive.file(appRoot.path + "/template/[Content_Types].xml", { name: "[Content_Types].xml" }); + // console.log(__dirname + "/packer.js"); + // this.archive.file(__dirname + "/packer.js", { name: "/[Content_Types].xml" }); /*this.archive.directory(appRoot.path + "/template", { name: "/root/g.txt", prefix: "root" });*/ - var xmlDocument = xml(this.formatter.format(this.document)); - var xmlStyles = xml(this.formatter.format(this.style)); - var xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: 'yes', encoding: 'UTF-8' } }); - var xmlNumbering = xml(this.formatter.format(this.numbering)); - //console.log(JSON.stringify(this.numbering, null, " ")); - console.log(xmlNumbering); + let xmlDocument = xml(this.formatter.format(this.document)); + let xmlStyles = xml(this.formatter.format(this.style)); + let xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: "yes", encoding: "UTF-8" } }); + let xmlNumbering = xml(this.formatter.format(this.numbering)); + // console.log(JSON.stringify(this.numbering, null, " ")); + console.log(xmlNumbering); this.archive.append(xmlDocument, { - name: 'word/document.xml' + name: "word/document.xml" }); this.archive.append(xmlStyles, { - name: 'word/styles.xml' + name: "word/styles.xml" }); this.archive.append(xmlProperties, { - name: 'docProps/core.xml' + name: "docProps/core.xml" }); - + this.archive.append(xmlNumbering, { - name: 'word/numbering.xml' - }) + name: "word/numbering.xml" + }); this.archive.finalize(); } diff --git a/ts/numbering/abstract-numbering.ts b/ts/numbering/abstract-numbering.ts index f5efd1811f..1839c25389 100644 --- a/ts/numbering/abstract-numbering.ts +++ b/ts/numbering/abstract-numbering.ts @@ -5,12 +5,12 @@ import {MultiLevelType} from "./multi-level-type"; import * as _ from "lodash"; interface AbstractNumberingAttributesProperties { - abstractNumId?: Number, - restartNumberingAfterBreak?: Number + abstractNumId?: number; + restartNumberingAfterBreak?: number; } class AbstractNumberingAttributes extends XmlAttributeComponent { - + constructor(properties: AbstractNumberingAttributesProperties) { super({ abstractNumId: "w:abstractNumId", @@ -29,11 +29,11 @@ export class AbstractNumbering extends XmlComponent { })); this.root.push(new MultiLevelType("hybridMultilevel")); } - + addLevel(level: Level): void { this.root.push(level); } - + clearVariables() { _.forEach(this.root, element => { element.clearVariables(); diff --git a/ts/numbering/indent.ts b/ts/numbering/indent.ts index 5835b4b777..05477f5d20 100644 --- a/ts/numbering/indent.ts +++ b/ts/numbering/indent.ts @@ -1,12 +1,12 @@ import {XmlComponent, XmlAttributeComponent} from "../docx/xml-components"; interface IndentAttributesProperties { - left: number; - hanging: number; + left: number; + hanging: number; } class IndentAttributes extends XmlAttributeComponent { - + constructor(properties: IndentAttributesProperties) { super({ left: "w:left", @@ -16,7 +16,7 @@ class IndentAttributes extends XmlAttributeComponent { } export class Indent extends XmlComponent { - + constructor(left: number, hanging: number) { super("w:ind"); this.root.push(new IndentAttributes({ diff --git a/ts/numbering/index.ts b/ts/numbering/index.ts index b624a4e452..5ca4ee3498 100644 --- a/ts/numbering/index.ts +++ b/ts/numbering/index.ts @@ -1,5 +1,5 @@ import {MultiPropertyXmlComponent} from "../docx/xml-components"; -import {DocumentAttributes} from "../docx/document/document-attributes" +import {DocumentAttributes} from "../docx/document/document-attributes"; import {AbstractNumbering} from "./abstract-numbering"; import {Level} from "./level"; import {Indent} from "./indent"; @@ -8,7 +8,7 @@ import {Num} from "./num"; import * as _ from "lodash"; export class Numbering extends MultiPropertyXmlComponent { - + constructor() { super("w:numbering"); this.root.push(new DocumentAttributes({ @@ -30,58 +30,58 @@ export class Numbering extends MultiPropertyXmlComponent { wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", Ignorable: "w14 w15 wp14" })); - - var abstractNumbering = new AbstractNumbering(0); - - var level0 = new Level(0, "bullet", "", "left"); + + let abstractNumbering = new AbstractNumbering(0); + + let level0 = new Level(0, "bullet", "", "left"); level0.addParagraphProperty(new Indent(720, 360)); level0.addRunProperty(new RunFonts("Symbol", "default")); abstractNumbering.addLevel(level0); - - var level1 = new Level(1, "bullet", "o", "left"); + + let level1 = new Level(1, "bullet", "o", "left"); level1.addParagraphProperty(new Indent(1440, 360)); level1.addRunProperty(new RunFonts("Courier New", "default")); abstractNumbering.addLevel(level1); - - var level2 = new Level(2, "bullet", "", "left"); + + let level2 = new Level(2, "bullet", "", "left"); level2.addParagraphProperty(new Indent(2160, 360)); level2.addRunProperty(new RunFonts("Wingdings", "default")); abstractNumbering.addLevel(level2); - - var level3 = new Level(3, "bullet", "", "left"); + + let level3 = new Level(3, "bullet", "", "left"); level3.addParagraphProperty(new Indent(2880, 360)); level3.addRunProperty(new RunFonts("Symbol", "default")); abstractNumbering.addLevel(level3); - - var level4 = new Level(4, "bullet", "o", "left"); + + let level4 = new Level(4, "bullet", "o", "left"); level4.addParagraphProperty(new Indent(3600, 360)); level4.addRunProperty(new RunFonts("Courier New", "default")); abstractNumbering.addLevel(level4); - - var level5 = new Level(5, "bullet", "", "left"); + + let level5 = new Level(5, "bullet", "", "left"); level5.addParagraphProperty(new Indent(4320, 360)); level5.addRunProperty(new RunFonts("Wingdings", "default")); abstractNumbering.addLevel(level5); - - var level6 = new Level(6, "bullet", "", "left"); + + let level6 = new Level(6, "bullet", "", "left"); level6.addParagraphProperty(new Indent(5040, 360)); level6.addRunProperty(new RunFonts("Symbol", "default")); abstractNumbering.addLevel(level6); - - var level7 = new Level(4, "bullet", "o", "left"); + + let level7 = new Level(4, "bullet", "o", "left"); level7.addParagraphProperty(new Indent(5760, 360)); level7.addRunProperty(new RunFonts("Courier New", "default")); abstractNumbering.addLevel(level7); - - var level8 = new Level(5, "bullet", "", "left"); + + let level8 = new Level(5, "bullet", "", "left"); level8.addParagraphProperty(new Indent(6480, 360)); level8.addRunProperty(new RunFonts("Wingdings", "default")); abstractNumbering.addLevel(level8); - + this.root.push(abstractNumbering); this.root.push(new Num(1, 0)); } - + clearVariables() { super.clearVariables(); _.forEach(this.root, element => { diff --git a/ts/numbering/level.ts b/ts/numbering/level.ts index 41b596507c..32c2625b02 100644 --- a/ts/numbering/level.ts +++ b/ts/numbering/level.ts @@ -4,8 +4,8 @@ import {RunProperties} from "../docx/run/properties"; import {ParagraphProperties} from "../docx/paragraph/properties"; interface LevelAttributesProperties { - ilvl?: number, - tentative?: number + ilvl?: number; + tentative?: number; } class LevelAttributes extends XmlAttributeComponent { diff --git a/ts/numbering/multi-level-type.ts b/ts/numbering/multi-level-type.ts index 4a0a291698..359b988e9c 100644 --- a/ts/numbering/multi-level-type.ts +++ b/ts/numbering/multi-level-type.ts @@ -1,7 +1,7 @@ import {XmlComponent, Attributes} from "../docx/xml-components"; export class MultiLevelType extends XmlComponent { - + constructor(value: string) { super("w:multiLevelType"); this.root.push(new Attributes({ diff --git a/ts/numbering/num.ts b/ts/numbering/num.ts index e5a861824e..2889b456ef 100644 --- a/ts/numbering/num.ts +++ b/ts/numbering/num.ts @@ -1,7 +1,7 @@ import {XmlComponent, Attributes, XmlAttributeComponent} from "../docx/xml-components"; class AbstractNumId extends XmlComponent { - + constructor(value: number) { super("w:abstractNumId"); this.root.push(new Attributes({ @@ -11,11 +11,11 @@ class AbstractNumId extends XmlComponent { } interface NumAttributesProperties { - numId: number + numId: number; } class NumAttributes extends XmlAttributeComponent { - + constructor(properties: NumAttributesProperties) { super({ numId: "w:numId" @@ -24,7 +24,7 @@ class NumAttributes extends XmlAttributeComponent { } export class Num extends XmlComponent { - + constructor(numId: number, abstractNumId: number) { super("w:num"); this.root.push(new NumAttributes({ diff --git a/ts/numbering/run-fonts.ts b/ts/numbering/run-fonts.ts index 6d1e95a547..cc5c640702 100644 --- a/ts/numbering/run-fonts.ts +++ b/ts/numbering/run-fonts.ts @@ -1,13 +1,13 @@ import {XmlComponent, XmlAttributeComponent} from "../docx/xml-components"; interface RunFontAttributesProperties { - ascii: string; - hAnsi: string; - hint: string; + ascii: string; + hAnsi: string; + hint: string; } class RunFontAttributes extends XmlAttributeComponent { - + constructor(properties: RunFontAttributesProperties) { super({ left: "w:left", @@ -17,7 +17,7 @@ class RunFontAttributes extends XmlAttributeComponent { } export class RunFonts extends XmlComponent { - + constructor(ascii: string, hint: string) { super("w:ind"); this.root.push(new RunFontAttributes({ diff --git a/ts/properties/components.ts b/ts/properties/components.ts index d5cff42284..1e6e44cb7a 100644 --- a/ts/properties/components.ts +++ b/ts/properties/components.ts @@ -43,7 +43,7 @@ export class Description extends XmlUnitComponent { } export class LastModifiedBy extends XmlUnitComponent { - + constructor(value: string) { super("cp:lastModifiedBy"); this.root = value; @@ -54,22 +54,22 @@ export class Revision extends XmlUnitComponent { constructor(value: string) { super("cp:revision"); - var revision = value; + let revision = value; this.root = value; } } abstract class DateComponent extends XmlComponent { protected getCurrentDate(): any { - var date = new Date(), + let date = new Date(), year = date.getFullYear(), - month = ('0' + (date.getMonth() + 1)).slice(-2), - day = ('0' + date.getDate()).slice(-2), - hours = ('0' + date.getHours()).slice(-2), - minutes = ('0' + date.getMinutes()).slice(-2), - seconds = ('0' + date.getSeconds()).slice(-2); + month = ("0" + (date.getMonth() + 1)).slice(-2), + day = ("0" + date.getDate()).slice(-2), + hours = ("0" + date.getHours()).slice(-2), + minutes = ("0" + date.getMinutes()).slice(-2), + seconds = ("0" + date.getSeconds()).slice(-2); - return year + '-' + month + '-' + day + 'T' + hours + ':' + minutes + ':' + seconds + 'Z'; + return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z"; } } diff --git a/ts/styles/defaults/index.ts b/ts/styles/defaults/index.ts index 0a944a978e..7b74e1d311 100644 --- a/ts/styles/defaults/index.ts +++ b/ts/styles/defaults/index.ts @@ -3,10 +3,10 @@ import {ParagraphPropertiesDefaults} from "./paragraph-properties"; import {RunPropertiesDefaults} from "./run-properties"; export class DocumentDefaults extends XmlComponent { - + private runPropertiesDefaults: RunPropertiesDefaults; private paragraphPropertiesDefaults: ParagraphPropertiesDefaults; - + constructor() { super("w:docDefaults"); this.runPropertiesDefaults = new RunPropertiesDefaults(); @@ -14,7 +14,7 @@ export class DocumentDefaults extends XmlComponent { this.root.push(this.runPropertiesDefaults); this.root.push(this.paragraphPropertiesDefaults); } - + clearVariables(): void { this.runPropertiesDefaults.clearVariables(); this.paragraphPropertiesDefaults.clearVariables(); diff --git a/ts/styles/defaults/run-properties.ts b/ts/styles/defaults/run-properties.ts index 7b76728083..e3c14a20a1 100644 --- a/ts/styles/defaults/run-properties.ts +++ b/ts/styles/defaults/run-properties.ts @@ -5,6 +5,6 @@ export class RunPropertiesDefaults extends XmlComponent { constructor() { super("w:rPrDefault"); - this.root.push(new RunProperties()); + this.root.push(new RunProperties()); } } \ No newline at end of file diff --git a/ts/styles/factory.ts b/ts/styles/factory.ts index d99d0fc57d..9907157dd3 100644 --- a/ts/styles/factory.ts +++ b/ts/styles/factory.ts @@ -3,7 +3,7 @@ import {DocumentDefaults} from "./defaults"; import {ParagraphPropertiesDefaults} from "./defaults/paragraph-properties"; import {RunPropertiesDefaults} from "./defaults/run-properties"; import {Heading1Style, Heading2Style, TitleStyle, Heading3Style, Heading4Style, Heading5Style, Heading6Style, ListParagraph} from "./style"; -//import {StyleAttributes} from "./style/attributes"; +// import {StyleAttributes} from "./style/attributes"; import {ParagraphProperties} from "../docx/paragraph/properties"; import {RunProperties} from "../docx/run/properties"; import {Color, Size, Italics} from "../docx/run/formatting"; @@ -11,46 +11,46 @@ import {Color, Size, Italics} from "../docx/run/formatting"; export class DefaultStylesFactory { newInstance(): Styles { - var styles = new Styles(); + let styles = new Styles(); styles.push(new DocumentDefaults()); - var titleStyle = new TitleStyle(); + let titleStyle = new TitleStyle(); titleStyle.addRunProperty(new Size(56)); styles.push(titleStyle); - var heading1Style = new Heading1Style(); + let heading1Style = new Heading1Style(); heading1Style.addRunProperty(new Color("2E74B5")); heading1Style.addRunProperty(new Size(32)); styles.push(heading1Style); - var heading2Style = new Heading2Style(); + let heading2Style = new Heading2Style(); heading2Style.addRunProperty(new Color("2E74B5")); heading2Style.addRunProperty(new Size(26)); styles.push(heading2Style); - var heading3Style = new Heading3Style(); + let heading3Style = new Heading3Style(); heading3Style.addRunProperty(new Color("1F4D78")); heading3Style.addRunProperty(new Size(24)); styles.push(heading3Style); - var heading4Style = new Heading4Style(); + let heading4Style = new Heading4Style(); heading4Style.addRunProperty(new Color("2E74B5")); heading4Style.addRunProperty(new Italics()); styles.push(heading4Style); - var heading5Style = new Heading5Style(); + let heading5Style = new Heading5Style(); heading5Style.addRunProperty(new Color("2E74B5")); styles.push(heading5Style); - var heading6Style = new Heading6Style(); + let heading6Style = new Heading6Style(); heading6Style.addRunProperty(new Color("1F4D78")); styles.push(heading6Style); - - var listParagraph = new ListParagraph(); - //listParagraph.addParagraphProperty(); + + let listParagraph = new ListParagraph(); + // listParagraph.addParagraphProperty(); styles.push(listParagraph); - //console.log(JSON.stringify(styles, null, " ")); + // console.log(JSON.stringify(styles, null, " ")); return styles; } } \ No newline at end of file diff --git a/ts/styles/index.ts b/ts/styles/index.ts index 4f87d0b6d3..ebf66dd56b 100644 --- a/ts/styles/index.ts +++ b/ts/styles/index.ts @@ -1,5 +1,5 @@ import {XmlComponent} from "../docx/xml-components"; -import {DocumentAttributes} from "../docx/document/document-attributes" +import {DocumentAttributes} from "../docx/document/document-attributes"; import {DocumentDefaults} from "./defaults"; import {LatentStyles} from "./latent-styles"; import {LatentStyleException} from "./latent-styles/exceptions"; @@ -16,21 +16,21 @@ export class Styles extends XmlComponent { w14: "http://schemas.microsoft.com/office/word/2010/wordml", w15: "http://schemas.microsoft.com/office/word/2012/wordml", Ignorable: "w14 w15" - })) - //var latentStyles = new LatentStyles(); - //latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({ + })); + // let latentStyles = new LatentStyles(); + // latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({ // name: "Normal" - //}))); - //this.root.push(latentStyles); + // }))); + // this.root.push(latentStyles); } push(style: XmlComponent): void { this.root.push(style); } - + clearVariables() { this.root.forEach(element => { element.clearVariables(); - }) + }); } } \ No newline at end of file diff --git a/ts/styles/latent-styles/exceptions/attributes.ts b/ts/styles/latent-styles/exceptions/attributes.ts index 72e3862934..4c2eaa2786 100644 --- a/ts/styles/latent-styles/exceptions/attributes.ts +++ b/ts/styles/latent-styles/exceptions/attributes.ts @@ -2,10 +2,10 @@ import {XmlComponent} from "../../../docx/xml-components"; interface LatentStyleExceptionAttributesProperties { name?: string; - uiPriority?: string, - qFormat?: string, - semiHidden?: string, - unhideWhenUsed?: string + uiPriority?: string; + qFormat?: string; + semiHidden?: string; + unhideWhenUsed?: string; } export class LatentStyleExceptionAttributes extends XmlComponent { @@ -21,7 +21,7 @@ export class LatentStyleExceptionAttributes extends XmlComponent { constructor(properties?: LatentStyleExceptionAttributesProperties) { super("_attr"); - this._attr = properties + this._attr = properties; if (!properties) { this._attr = {}; diff --git a/ts/styles/latent-styles/index.ts b/ts/styles/latent-styles/index.ts index f6b5c9f617..fe75c11e37 100644 --- a/ts/styles/latent-styles/index.ts +++ b/ts/styles/latent-styles/index.ts @@ -2,11 +2,11 @@ import {XmlComponent} from "../../docx/xml-components"; import {LatentStyleException} from "./exceptions"; export class LatentStyles extends XmlComponent { - + constructor() { super("w:latentStyles"); } - + push(latentException: LatentStyleException): void { this.root.push(latentException); } diff --git a/ts/styles/style/components.ts b/ts/styles/style/components.ts index e815a99600..f7853169d1 100644 --- a/ts/styles/style/components.ts +++ b/ts/styles/style/components.ts @@ -57,7 +57,7 @@ export class UnhideWhenUsed extends XmlComponent { } export class QuickFormat extends XmlComponent { - + constructor() { super("w:qFormat"); } diff --git a/ts/styles/style/index.ts b/ts/styles/style/index.ts index 07c244bbe4..412667ea81 100644 --- a/ts/styles/style/index.ts +++ b/ts/styles/style/index.ts @@ -23,7 +23,7 @@ export class ParagraphStyle extends Style { constructor(styleId: string) { - var attributes = new StyleAttributes({ + let attributes = new StyleAttributes({ type: "paragraph", styleId: styleId }); @@ -111,7 +111,7 @@ export class Heading6Style extends HeadingStyle { } export class ListParagraph extends ParagraphStyle { - + constructor() { super("ListParagraph"); this.root.push(new Name("List Paragraph")); diff --git a/ts/tests/attributeTest.ts b/ts/tests/attributeTest.ts index 043658818f..f384e73d4b 100644 --- a/ts/tests/attributeTest.ts +++ b/ts/tests/attributeTest.ts @@ -4,36 +4,36 @@ import {Attributes} from "../docx/xml-components"; import {assert} from "chai"; describe("Attribute", () => { - var attributes: Attributes; + let attributes: Attributes; beforeEach(() => { attributes = new Attributes(); }); - describe('#constructor()', () => { + describe("#constructor()", () => { it("should not add val with empty constructor", () => { - var newAttrs = new Attributes(); - var stringifiedJson = JSON.stringify(newAttrs); - var newJson = JSON.parse(stringifiedJson); + let newAttrs = new Attributes(); + let stringifiedJson = JSON.stringify(newAttrs); + let newJson = JSON.parse(stringifiedJson); assert.isUndefined(newJson.root.val); }); it("should have val as defined with populated constructor", () => { - var newAttrs = new Attributes({ + let newAttrs = new Attributes({ val: "test" }); - var stringifiedJson = JSON.stringify(newAttrs); - var newJson = JSON.parse(stringifiedJson); + let stringifiedJson = JSON.stringify(newAttrs); + let newJson = JSON.parse(stringifiedJson); assert.equal(newJson.root.val, "test"); }); it("should have space value as defined with populated constructor", () => { - var newAttrs = new Attributes({ + let newAttrs = new Attributes({ space: "spaceTest" }); - var stringifiedJson = JSON.stringify(newAttrs); - var newJson = JSON.parse(stringifiedJson); + let stringifiedJson = JSON.stringify(newAttrs); + let newJson = JSON.parse(stringifiedJson); assert.equal(newJson.root.space, "spaceTest"); }); }); diff --git a/ts/tests/bodyTest.ts b/ts/tests/bodyTest.ts index e941b7243c..a3112dfbd6 100644 --- a/ts/tests/bodyTest.ts +++ b/ts/tests/bodyTest.ts @@ -9,12 +9,12 @@ import {Columns} from "../docx/document/body/columns"; import {DocumentGrid} from "../docx/document/body/doc-grid"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } describe("Body", () => { - var body: Body; + let body: Body; beforeEach(() => { body = new Body(); @@ -28,27 +28,27 @@ describe("Body", () => { describe("#constructor()", () => { it("should create the Section Properties", () => { - var newJson = jsonify(body); + let newJson = jsonify(body); assert.equal(newJson.root[0].rootKey, "w:sectPr"); }); it("should create the Page Size", () => { - var newJson = jsonify(body); + let newJson = jsonify(body); assert.equal(newJson.root[1].rootKey, "w:pgSz"); }); it("should create the Page Margin", () => { - var newJson = jsonify(body); + let newJson = jsonify(body); assert.equal(newJson.root[2].rootKey, "w:pgMar"); }); it("should create the Columns", () => { - var newJson = jsonify(body); + let newJson = jsonify(body); assert.equal(newJson.root[3].rootKey, "w:cols"); }); it("should create the Document Grid", () => { - var newJson = jsonify(body); + let newJson = jsonify(body); assert.equal(newJson.root[4].rootKey, "w:docGrid"); }); }); diff --git a/ts/tests/borderTest.ts b/ts/tests/borderTest.ts index 940c183991..27b1dfdd15 100644 --- a/ts/tests/borderTest.ts +++ b/ts/tests/borderTest.ts @@ -4,7 +4,7 @@ import {ThematicBreak} from "../docx/paragraph/border"; import {assert} from "chai"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } @@ -13,7 +13,7 @@ describe("Border", () => { }); describe("ThematicBreak", () => { - var thematicBreak: ThematicBreak; + let thematicBreak: ThematicBreak; beforeEach(() => { thematicBreak = new ThematicBreak(); @@ -21,8 +21,8 @@ describe("ThematicBreak", () => { describe("#constructor()", () => { it("should create a Thematic Break with correct border properties", () => { - var newJson = jsonify(thematicBreak); - var attributes = { + let newJson = jsonify(thematicBreak); + let attributes = { color: "auto", space: "1", val: "single", @@ -30,5 +30,5 @@ describe("ThematicBreak", () => { }; assert.equal(JSON.stringify(newJson.root[0].root[0].root), JSON.stringify(attributes)); }); - }) + }); }); \ No newline at end of file diff --git a/ts/tests/documentTest.ts b/ts/tests/documentTest.ts index ce77c00589..b5045033c3 100644 --- a/ts/tests/documentTest.ts +++ b/ts/tests/documentTest.ts @@ -4,18 +4,17 @@ import * as docx from "../docx"; import {assert} from "chai"; describe("Document", () => { - var document: docx.Document; + let document: docx.Document; beforeEach(() => { document = new docx.Document(); }); - describe('#constructor()', () => { - + describe("#constructor()", () => { + it("should create valid JSON", () => { - //console.log(JSON.stringify(document, null, " ")); - var stringifiedJson = JSON.stringify(document); - var newJson; + let stringifiedJson = JSON.stringify(document); + let newJson; try { newJson = JSON.parse(stringifiedJson); diff --git a/ts/tests/formatterTest.ts b/ts/tests/formatterTest.ts index d93e99fc7d..a5969b732a 100644 --- a/ts/tests/formatterTest.ts +++ b/ts/tests/formatterTest.ts @@ -10,70 +10,70 @@ import {Properties} from "../properties"; import {assert} from "chai"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } describe("Formatter", () => { - var formatter: Formatter; + let formatter: Formatter; beforeEach(() => { formatter = new Formatter(); }); - describe('#format()', () => { + describe("#format()", () => { it("should format simple paragraph", () => { - var paragraph = new docx.Paragraph(); - var newJson = formatter.format(paragraph); + let paragraph = new docx.Paragraph(); + let newJson = formatter.format(paragraph); newJson = jsonify(newJson); assert.isDefined(newJson["w:p"]); }); it("should remove xmlKeys", () => { - var paragraph = new docx.Paragraph(); - var newJson = formatter.format(paragraph); - var stringifiedJson = JSON.stringify(newJson); + let paragraph = new docx.Paragraph(); + let newJson = formatter.format(paragraph); + let stringifiedJson = JSON.stringify(newJson); assert(stringifiedJson.indexOf("xmlKeys") < 0); }); it("should format simple paragraph with bold text", () => { - var paragraph = new docx.Paragraph(); + let paragraph = new docx.Paragraph(); paragraph.addText(new docx.TextRun("test").bold()); - var newJson = formatter.format(paragraph); + let newJson = formatter.format(paragraph); newJson = jsonify(newJson); assert.isDefined(newJson["w:p"][1]["w:r"][0]["w:rPr"][0]["w:b"][0]["_attr"]["w:val"]); }); it("should format attributes (rsidSect)", () => { - var attributes = new Attributes({ + let attributes = new Attributes({ rsidSect: "test2" }); - var newJson = formatter.format(attributes); + let newJson = formatter.format(attributes); newJson = jsonify(newJson); assert.isDefined(newJson["_attr"]["w:rsidSect"]); }); it("should format attributes (val)", () => { - var attributes = new Attributes({ + let attributes = new Attributes({ val: "test" }); - var newJson = formatter.format(attributes); + let newJson = formatter.format(attributes); newJson = jsonify(newJson); assert.isDefined(newJson["_attr"]["w:val"]); }); it("should should change 'p' tag into 'w:p' tag", () => { - var paragraph = new docx.Paragraph(); - var newJson = formatter.format(paragraph); + let paragraph = new docx.Paragraph(); + let newJson = formatter.format(paragraph); assert.isDefined(newJson["w:p"]); }); it("should format Properties object correctly", () => { - var properties = new Properties({ + let properties = new Properties({ title: "test document", creator: "Dolan" }); - var newJson = formatter.format(properties); + let newJson = formatter.format(properties); newJson = jsonify(newJson); assert.isDefined(newJson["cp:coreProperties"]); }); diff --git a/ts/tests/localPackerTest.ts b/ts/tests/localPackerTest.ts index 40569f0bd4..2d4509f2d9 100644 --- a/ts/tests/localPackerTest.ts +++ b/ts/tests/localPackerTest.ts @@ -5,35 +5,35 @@ import {LocalPacker} from "../export/packer/local"; import {assert} from "chai"; -import {Document} from "../docx/document" -import {Properties} from "../properties" -import {DefaultStyle} from "../styles/sample" -import {Paragraph} from "../docx/paragraph" -import {DefaultStylesFactory} from "../styles/factory" +import {Document} from "../docx/document"; +import {Properties} from "../properties"; +import {DefaultStyle} from "../styles/sample"; +import {Paragraph} from "../docx/paragraph"; +import {DefaultStylesFactory} from "../styles/factory"; describe.only("Packer", () => { - var packer: LocalPacker; - var stylesFactory: DefaultStylesFactory; + let packer: LocalPacker; + let stylesFactory: DefaultStylesFactory; beforeEach(() => { - var document = new Document(); - var paragraph = new Paragraph("test text"); - var heading = new Paragraph("Hello world").heading1(); + let document = new Document(); + let paragraph = new Paragraph("test text"); + let heading = new Paragraph("Hello world").heading1(); document.addParagraph(new Paragraph("title").title()); document.addParagraph(heading); document.addParagraph(new Paragraph("heading 2").heading2()); document.addParagraph(paragraph); - var properties = new Properties({ + let properties = new Properties({ creator: "Shan Fu", revision: "1", lastModifiedBy: "Shan Fu" }); stylesFactory = new DefaultStylesFactory(); packer = new LocalPacker(document, stylesFactory.newInstance(), properties, "build/tests/test.docx"); - //packer = new LocalPacker(document, DefaultStyle(), properties, "build/tests/test.docx"); + // packer = new LocalPacker(document, DefaultStyle(), properties, "build/tests/test.docx"); }); - describe('#pack()', () => { + describe("#pack()", () => { it("should create a standard docx file", (done) => { packer.pack(); diff --git a/ts/tests/paragraphStyleTest.ts b/ts/tests/paragraphStyleTest.ts index 346e06f943..46e5b71d54 100644 --- a/ts/tests/paragraphStyleTest.ts +++ b/ts/tests/paragraphStyleTest.ts @@ -4,23 +4,23 @@ import {Style} from "../docx/paragraph/style"; import {assert} from "chai"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } describe("ParagraphStyle", () => { - var style: Style; + let style: Style; describe("#constructor()", () => { it("should create a style with given value", () => { style = new Style("test"); - var newJson = jsonify(style); + let newJson = jsonify(style); assert.equal(newJson.root[0].root.val, "test"); }); it("should create a style with blank val", () => { style = new Style(""); - var newJson = jsonify(style); + let newJson = jsonify(style); assert.equal(newJson.root[0].root.val, ""); }); }); diff --git a/ts/tests/paragraphTest.ts b/ts/tests/paragraphTest.ts index 2dcab1182a..fa31a16179 100644 --- a/ts/tests/paragraphTest.ts +++ b/ts/tests/paragraphTest.ts @@ -4,22 +4,22 @@ import * as docx from "../docx"; import {assert} from "chai"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } describe("Paragraph", () => { - var paragraph: docx.Paragraph; + let paragraph: docx.Paragraph; beforeEach(() => { paragraph = new docx.Paragraph(); }); - describe('#constructor()', () => { + describe("#constructor()", () => { it("should create valid JSON", () => { - var stringifiedJson = JSON.stringify(paragraph); - var newJson; + let stringifiedJson = JSON.stringify(paragraph); + let newJson; try { newJson = JSON.parse(stringifiedJson); @@ -30,8 +30,8 @@ describe("Paragraph", () => { }); it("should create have valid properties", () => { - var stringifiedJson = JSON.stringify(paragraph); - var newJson = JSON.parse(stringifiedJson); + let stringifiedJson = JSON.stringify(paragraph); + let newJson = JSON.parse(stringifiedJson); assert.equal(newJson.root[0].rootKey, "w:pPr"); }); }); @@ -39,7 +39,7 @@ describe("Paragraph", () => { describe("#heading1()", () => { it("should add heading style to JSON", () => { paragraph.heading1(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[0].root.val, "Heading1"); }); }); @@ -47,7 +47,7 @@ describe("Paragraph", () => { describe("#heading2()", () => { it("should add heading style to JSON", () => { paragraph.heading2(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[0].root.val, "Heading2"); }); @@ -56,7 +56,7 @@ describe("Paragraph", () => { describe("#heading3()", () => { it("should add heading style to JSON", () => { paragraph.heading3(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[0].root.val, "Heading3"); }); @@ -65,7 +65,7 @@ describe("Paragraph", () => { describe("#title()", () => { it("should add title style to JSON", () => { paragraph.title(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[0].root.val, "Title"); }); @@ -74,7 +74,7 @@ describe("Paragraph", () => { describe("#center()", () => { it("should add center alignment to JSON", () => { paragraph.center(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[0].root.val, "center"); }); @@ -83,7 +83,7 @@ describe("Paragraph", () => { describe("#thematicBreak()", () => { it("should add thematic break to JSON", () => { paragraph.thematicBreak(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].rootKey, "w:pBdr"); }); }); @@ -91,13 +91,13 @@ describe("Paragraph", () => { describe("#pageBreak()", () => { it("should add page break to JSON", () => { paragraph.pageBreak(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[1].rootKey, "w:br"); }); it("should add page break with 'page' type", () => { paragraph.pageBreak(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[1].root[0].root.type, "page"); }); }); @@ -105,13 +105,13 @@ describe("Paragraph", () => { describe("#bullet()", () => { it("should add list paragraph style to JSON", () => { paragraph.bullet(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.equal(newJson.root[0].root[1].root[0].root.val, "ListParagraph"); }); it("it should add numbered properties", () => { paragraph.bullet(); - var newJson = jsonify(paragraph); + let newJson = jsonify(paragraph); assert.isDefined(newJson.root[0].root[2]); }); }); diff --git a/ts/tests/propertiesTest.ts b/ts/tests/propertiesTest.ts index 5f5b838895..9888da7859 100644 --- a/ts/tests/propertiesTest.ts +++ b/ts/tests/propertiesTest.ts @@ -4,12 +4,12 @@ import {Properties} from "../properties"; import {assert} from "chai"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } describe("Properties", () => { - var properties: Properties; + let properties: Properties; beforeEach(() => { @@ -20,8 +20,8 @@ describe("Properties", () => { properties = new Properties({ title: "test document" }); - var newJson = jsonify(properties); + let newJson = jsonify(properties); assert(newJson.root[1].root === "test document"); }); - }) + }); }); \ No newline at end of file diff --git a/ts/tests/runTest.ts b/ts/tests/runTest.ts index 5b0c819e43..7b59035538 100644 --- a/ts/tests/runTest.ts +++ b/ts/tests/runTest.ts @@ -1,54 +1,54 @@ /// /// import {Run} from "../docx/run"; -import {TextRun} from "../docx//run/text-run" +import {TextRun} from "../docx//run/text-run"; import {assert} from "chai"; function jsonify(obj: Object) { - var stringifiedJson = JSON.stringify(obj); + let stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); } describe("Run", () => { - var run: Run; + let run: Run; beforeEach(() => { run = new Run(); }); - describe('#bold()', () => { + describe("#bold()", () => { it("it should add bold to the properties", () => { run.bold(); - var newJson = jsonify(run); + let newJson = jsonify(run); assert.equal(newJson.root[0].root[0].rootKey, "w:b"); }); }); - describe('#italic()', () => { + describe("#italic()", () => { it("it should add italics to the properties", () => { run.italic(); - var newJson = jsonify(run); + let newJson = jsonify(run); assert.equal(newJson.root[0].root[0].rootKey, "w:i"); }); }); - describe('#underline()', () => { + describe("#underline()", () => { it("it should add underline to the properties", () => { run.underline(); - var newJson = jsonify(run); + let newJson = jsonify(run); assert.equal(newJson.root[0].root[0].rootKey, "w:u"); }); }); }); -describe('TextRun', () => { - var run: TextRun; +describe("TextRun", () => { + let run: TextRun; - describe('#constructor()', () => { + describe("#constructor()", () => { it("should add text into run", () => { run = new TextRun("test"); - var newJson = jsonify(run); + let newJson = jsonify(run); assert.equal(newJson.root[1].root, "test"); }); }); diff --git a/ts/tests/stylesTest.ts b/ts/tests/stylesTest.ts index 8e2d24021d..f38999c468 100644 --- a/ts/tests/stylesTest.ts +++ b/ts/tests/stylesTest.ts @@ -4,19 +4,19 @@ import {Styles} from "../styles"; import {assert} from "chai"; describe("Styles", () => { - var styles: Styles; + let styles: Styles; beforeEach(() => { styles = new Styles(); }); - describe('#constructor()', () => { + describe("#constructor()", () => { it("should create styles with correct rootKey", () => { - var styles = new Styles(); - var stringifiedJson = JSON.stringify(styles); - var newJson = JSON.parse(stringifiedJson); - + let styles = new Styles(); + let stringifiedJson = JSON.stringify(styles); + let newJson = JSON.parse(stringifiedJson); + assert.equal(newJson.rootKey, "w:styles"); }); });