Fix tests
This commit is contained in:
@ -3,6 +3,8 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
import { Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
|
// tslint:disable:no-shadowed-variable
|
||||||
|
|
||||||
const PHONE_NUMBER = "07534563401";
|
const PHONE_NUMBER = "07534563401";
|
||||||
const PROFILE_URL = "https://www.linkedin.com/in/dolan1";
|
const PROFILE_URL = "https://www.linkedin.com/in/dolan1";
|
||||||
const EMAIL = "docx@com";
|
const EMAIL = "docx@com";
|
||||||
@ -125,11 +127,13 @@ const achievements = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
class DocumentCreator {
|
class DocumentCreator {
|
||||||
public create(data): Document {
|
public create(data: object[]): Document {
|
||||||
const experiences = data[0];
|
// tslint:disable-next-line:no-any
|
||||||
const educations = data[1];
|
const experiences = data[0] as any[];
|
||||||
const skills = data[2];
|
// tslint:disable-next-line:no-any
|
||||||
const achivements = data[3];
|
const educations = data[1] as any[];
|
||||||
|
const skills = data[2] as object[];
|
||||||
|
const achivements = data[3] as object[];
|
||||||
const document = new Document();
|
const document = new Document();
|
||||||
document.addParagraph(new Paragraph("Dolan Miu").title());
|
document.addParagraph(new Paragraph("Dolan Miu").title());
|
||||||
|
|
||||||
@ -197,7 +201,7 @@ class DocumentCreator {
|
|||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
createContactInfo(phoneNumber: string, profileUrl: string, email: string) {
|
public createContactInfo(phoneNumber: string, profileUrl: string, email: string): Paragraph {
|
||||||
const paragraph = new Paragraph().center();
|
const paragraph = new Paragraph().center();
|
||||||
const contactInfo = new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`);
|
const contactInfo = new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`);
|
||||||
const address = new TextRun("Address: 58 Elm Avenue, Kent ME4 6ER, UK").break();
|
const address = new TextRun("Address: 58 Elm Avenue, Kent ME4 6ER, UK").break();
|
||||||
@ -208,15 +212,15 @@ class DocumentCreator {
|
|||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
createHeading(text) {
|
public createHeading(text: string): Paragraph {
|
||||||
return new Paragraph(text).heading1().thematicBreak();
|
return new Paragraph(text).heading1().thematicBreak();
|
||||||
}
|
}
|
||||||
|
|
||||||
createSubHeading(text) {
|
public createSubHeading(text: string): Paragraph {
|
||||||
return new Paragraph(text).heading2();
|
return new Paragraph(text).heading2();
|
||||||
}
|
}
|
||||||
|
|
||||||
createInstitutionHeader(institutionName, dateText) {
|
public createInstitutionHeader(institutionName: string, dateText: string): Paragraph {
|
||||||
const paragraph = new Paragraph().maxRightTabStop();
|
const paragraph = new Paragraph().maxRightTabStop();
|
||||||
const institution = new TextRun(institutionName).bold();
|
const institution = new TextRun(institutionName).bold();
|
||||||
const date = new TextRun(dateText).tab().bold();
|
const date = new TextRun(dateText).tab().bold();
|
||||||
@ -227,7 +231,7 @@ class DocumentCreator {
|
|||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoleText(roleText) {
|
public createRoleText(roleText: string): Paragraph {
|
||||||
const paragraph = new Paragraph();
|
const paragraph = new Paragraph();
|
||||||
const role = new TextRun(roleText).italic();
|
const role = new TextRun(roleText).italic();
|
||||||
|
|
||||||
@ -236,11 +240,12 @@ class DocumentCreator {
|
|||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
createBullet(text) {
|
public createBullet(text: string): Paragraph {
|
||||||
return new Paragraph(text).bullet();
|
return new Paragraph(text).bullet();
|
||||||
}
|
}
|
||||||
|
|
||||||
createSkillList(skills) {
|
// tslint:disable-next-line:no-any
|
||||||
|
public createSkillList(skills: any[]): Paragraph {
|
||||||
const paragraph = new Paragraph();
|
const paragraph = new Paragraph();
|
||||||
const skillConcat = skills.map((skill) => skill.name).join(", ") + ".";
|
const skillConcat = skills.map((skill) => skill.name).join(", ") + ".";
|
||||||
|
|
||||||
@ -249,35 +254,38 @@ class DocumentCreator {
|
|||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public createAchivementsList(achivements): Paragraph {
|
// tslint:disable-next-line:no-any
|
||||||
const arr = [];
|
public createAchivementsList(achivements: any[]): Paragraph[] {
|
||||||
|
const arr: Paragraph[] = [];
|
||||||
|
|
||||||
for (const achievement of achivements) {
|
for (const achievement of achivements) {
|
||||||
arr.push(new Paragraph(achievement.name).bullet());
|
const paragraph = new Paragraph(achievement.name).bullet();
|
||||||
|
arr.push(paragraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterests(interests) {
|
public createInterests(interests: string): Paragraph {
|
||||||
const paragraph = new Paragraph();
|
const paragraph = new Paragraph();
|
||||||
|
|
||||||
paragraph.addRun(new TextRun(interests));
|
paragraph.addRun(new TextRun(interests));
|
||||||
return paragraph;
|
return paragraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
splitParagraphIntoBullets(text) {
|
public splitParagraphIntoBullets(text: string): string[] {
|
||||||
return text.split("\n\n");
|
return text.split("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
createPositionDateText(startDate, endDate, isCurrent) {
|
// tslint:disable-next-line:no-any
|
||||||
|
public createPositionDateText(startDate: any, endDate: any, isCurrent: boolean): string {
|
||||||
const startDateText = this.getMonthFromInt(startDate.month) + ". " + startDate.year;
|
const startDateText = this.getMonthFromInt(startDate.month) + ". " + startDate.year;
|
||||||
const endDateText = isCurrent ? "Present" : `${this.getMonthFromInt(endDate.month)}. ${endDate.year}`;
|
const endDateText = isCurrent ? "Present" : `${this.getMonthFromInt(endDate.month)}. ${endDate.year}`;
|
||||||
|
|
||||||
return `${startDateText} - ${endDateText}`;
|
return `${startDateText} - ${endDateText}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMonthFromInt(value) {
|
public getMonthFromInt(value: number): string {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 1:
|
case 1:
|
||||||
return "Jan";
|
return "Jan";
|
||||||
@ -303,6 +311,8 @@ class DocumentCreator {
|
|||||||
return "Nov";
|
return "Nov";
|
||||||
case 12:
|
case 12:
|
||||||
return "Dec";
|
return "Dec";
|
||||||
|
default:
|
||||||
|
return "N/A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ doc.Styles.createParagraphStyle("Heading1", "Heading 1")
|
|||||||
.size(52)
|
.size(52)
|
||||||
.center()
|
.center()
|
||||||
.bold()
|
.bold()
|
||||||
.color(000000)
|
.color("000000")
|
||||||
.spacing({ line: 340 })
|
.spacing({ line: 340 })
|
||||||
.underline("single", "000000");
|
.underline("single", "000000");
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ table
|
|||||||
.getRow(0)
|
.getRow(0)
|
||||||
.getCell(0)
|
.getCell(0)
|
||||||
.addContent(new Paragraph("Pole No."));
|
.addContent(new Paragraph("Pole No."));
|
||||||
table.Properties.width = 10000;
|
// table.Properties.width = 10000;
|
||||||
doc.addTable(table);
|
doc.addTable(table);
|
||||||
|
|
||||||
const arrboth = [
|
const arrboth = [
|
||||||
@ -129,8 +129,8 @@ const arrboth = [
|
|||||||
arrboth.forEach((item) => {
|
arrboth.forEach((item) => {
|
||||||
const para = doc.createParagraph();
|
const para = doc.createParagraph();
|
||||||
para.addImage(doc.createImage(fs.readFileSync(item.image)));
|
para.addImage(doc.createImage(fs.readFileSync(item.image)));
|
||||||
para.Properties.width = 60;
|
// para.Properties.width = 60;
|
||||||
para.Properties.height = 90;
|
// para.Properties.height = 90;
|
||||||
doc.createParagraph(item.comment).style("normalPara2");
|
doc.createParagraph(item.comment).style("normalPara2");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -76,6 +76,10 @@ export class Table extends XmlComponent {
|
|||||||
this.properties.setFixedWidthLayout();
|
this.properties.setFixedWidthLayout();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get Properties(): TableProperties {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TableRow extends XmlComponent {
|
export class TableRow extends XmlComponent {
|
||||||
|
Reference in New Issue
Block a user