Commit 83172958 authored by Mark Stenglein's avatar Mark Stenglein

Add CI, fix a couple tests, kill .viscode folder

parent addafff2
Pipeline #898 failed with stage
in 0 seconds
...@@ -4,3 +4,5 @@ logs ...@@ -4,3 +4,5 @@ logs
# Dependency Directory # Dependency Directory
node_modules node_modules
.vscode/
image: node-latest
cache:
paths:
- node_modules/
types:
- test
test_lib-ical:
type: test
before_script:
- npm install
- npm install -g typescript ts-node gulp-cli
script:
- npm test
- gulp
// Place your settings in this file to overwrite default and user settings.
{
}
\ No newline at end of file
...@@ -13,17 +13,18 @@ const util_1 = require("./util"); ...@@ -13,17 +13,18 @@ const util_1 = require("./util");
* unfilled. * unfilled.
*/ */
class ContentLine { class ContentLine {
constructor(inName, inParam, inValue) { constructor(inName, inParams, inValue) {
this._params = [];
this.name = inName; this.name = inName;
this.param = inParam; this._params = inParams;
this.value = inValue; this.value = inValue;
} }
/* Getters */ /* Getters */
get name() { get name() {
return this._name; return this._name;
} }
get param() { get params() {
return this._param; return this._params;
} }
get value() { get value() {
return this._value; return this._value;
...@@ -37,13 +38,35 @@ class ContentLine { ...@@ -37,13 +38,35 @@ class ContentLine {
throw new TypeError("'name' must be alphabetic!"); throw new TypeError("'name' must be alphabetic!");
} }
} }
set param(newParam) {
this._param = newParam;
}
set value(newValue) { set value(newValue) {
if (util_1.isAlpha(newValue)) { if (util_1.isAlpha(newValue)) {
this._value = newValue; this._value = newValue;
} }
} }
/**
* Folds lines into 74 octet sections
*
* @author Sebastian Pekarek <mail@sebbo.net>
*
* TODO: Make sure that this handles multi-octed UTF-8 segments properly.
*/
static fold(line) {
return line.match(/(.{1,74})/g).join("\r\n ");
}
/**
* Generates a folded content line to use to create the final file.
*
* @author Mark Stenglein <mark@stengle.in>
*/
generate() {
let outputLine = this.name;
this.params.forEach((param) => {
outputLine += ";";
outputLine += param;
});
outputLine += ":" + this.value + "\r\n";
return ContentLine.fold(outputLine);
}
} }
exports.ContentLine = ContentLine; Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ContentLine;
...@@ -6,11 +6,11 @@ describe("ContentLine", () => { ...@@ -6,11 +6,11 @@ describe("ContentLine", () => {
it("Should exist", () => { it("Should exist", () => {
let result = true; let result = true;
if (typeof ContentLine == undefined) { if (typeof ContentLine === undefined) {
result = false; result = false;
} }
expect(result).to.be.true; expect(result).to.be.true;
}) });
}) });
...@@ -62,7 +62,7 @@ export default class ContentLine { ...@@ -62,7 +62,7 @@ export default class ContentLine {
* TODO: Make sure that this handles multi-octed UTF-8 segments properly. * TODO: Make sure that this handles multi-octed UTF-8 segments properly.
*/ */
static fold(line: string): string { static fold(line: string): string {
return line.match(/(.{1,74})/g).join('\r\n '); return line.match(/(.{1,74})/g).join("\r\n ");
} }
/** /**
...@@ -74,11 +74,11 @@ export default class ContentLine { ...@@ -74,11 +74,11 @@ export default class ContentLine {
let outputLine = this.name; let outputLine = this.name;
this.params.forEach((param) => { this.params.forEach((param) => {
outputLine += ';'; outputLine += ";";
outputLine += param; outputLine += param;
}); });
outputLine += ':' + this.value + '\r\n'; outputLine += ":" + this.value + "\r\n";
return ContentLine.fold(outputLine); return ContentLine.fold(outputLine);
} }
......
...@@ -8,12 +8,12 @@ describe("util", () => { ...@@ -8,12 +8,12 @@ describe("util", () => {
it("Should exist", () => { it("Should exist", () => {
let result = true; let result = true;
if (typeof isAlpha == undefined) { if (typeof isAlpha === undefined) {
result = false; result = false;
} }
expect(result).to.be.true; expect(result).to.be.true;
}) });
it("Should return false for numbers", () => { it("Should return false for numbers", () => {
let test = "12345"; let test = "12345";
...@@ -47,7 +47,7 @@ describe("util", () => { ...@@ -47,7 +47,7 @@ describe("util", () => {
let test = "ABCDEF"; let test = "ABCDEF";
let result = isAlpha(test); let result = isAlpha(test);
expect(result).to.be.true expect(result).to.be.true;
}); });
it("Should return true for mixed alpha", () => { it("Should return true for mixed alpha", () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment