Commit 972275e0 authored by Mark Stenglein's avatar Mark Stenglein

Adds a bunch more blank tests 💯

- I moved some of the methods out of util and into Parameter for
  the moment so that I can figure out what the problem is that is
  causing the Parameter to not construct properly.

  - I added a fake stub method in ContentLine which just returns
  true all the time for now just so that the test cases will still
  compile properly.

- At this point all of the tests need to be written so that I can
  isolate the issue and hopefully fix it. Getting close to being
  able to actually implement iCal features! 🎉
parent fb23ce5e
Pipeline #917 failed with stage
in 13 seconds
import { isIamaToken, isAlpha } from "./util";
import { isAlpha } from "./util";
import { ICalElement } from "./ICalElement";
import Parameter from "./Parameter";
const CRLF: string = "/r/n";
function isIamaToken(input: string): boolean {
return true;
}
/**
* Implementation of a Content Line from RFC 5545
......
import { isAlpha, isIamaToken, isXName } from "./util";
import { isAlpha } from "./util";
import { ICalElement } from "./ICalElement";
/**
......@@ -67,7 +67,7 @@ export default class Parameter implements ICalElement {
* Note that the X-Name also passes these rules, the X-Name can be
* defined separately.
*/
if (isIamaToken(newName) || isXName(newName)) {
if (Parameter.isIanaToken(newName) || Parameter.isXName(newName)) {
this._paramName = newName;
}
else {
......@@ -81,7 +81,7 @@ export default class Parameter implements ICalElement {
*
* param-value = paramtext / quoted-string
*
* @author
* @author Mark Stenglein <mark@stengle.in>
* @since 0.1.0
* @param newValues The input values to be tested and saved.
*/
......@@ -93,7 +93,7 @@ export default class Parameter implements ICalElement {
) {
throw new TypeError(
"param-value must either be valid paramtext or" +
"quoted-string"
" quoted-string"
);
}
})
......@@ -128,6 +128,45 @@ export default class Parameter implements ICalElement {
}
/**
* Checks to see if the input string is a compliant iama-token
*
* Definition of iana-token from the spec:
*
* iana-token = 1*(ALPHA / DIGIT / "-")
* ; iCalendar identifier registered with IANA
*
* @author Mark Stenglein <mark@stengle.in>
* @since 0.1.0
* @param input Input string to be tested
* @returns boolean value of if it is a valid token
*/
public static isIanaToken(input: string): boolean {
return /^[a-zA-Z0-9-]+$/.test(input);
}
/**
* Checks to see if the input string is a compliant x-token
*
* Definition of x-name from the spec:
*
* x-name = "X-" [vendorid "-"] 1*(ALPHA / DIGIT / "-")
* ; Reserved for experimental use.
*
* vendorid = 3*(ALPHA / DIGIT)
* ; Vendor identification
*
* @author Mark Stenglein <mark@stengle.in>
* @since 0.1.0
* @param input Input string to be tested
* @returns boolean value of if input is a valid experimental token
*
* TODO: Implement this!
*/
public static isXName(input: string): boolean {
return true;
}
/**
* Tests to make sure input is compliant with the definition of `param-text`
*
......
......@@ -29,7 +29,7 @@ export function isAlpha(input: string): boolean {
* @param input Input string to be tested
* @returns boolean value of if it is a valid token
*/
export function isIamaToken(input: string): boolean {
export function isIanaToken(input: string): boolean {
return /^[a-zA-Z0-9-]+$/.test(input);
}
......
......@@ -12,49 +12,186 @@ describe("Parameter", () => {
describe("constructor()", () => {
it("Should create an object", () => {
const result: Parameter = new Parameter("TestName", []);
const result: Parameter = new Parameter("TestName", ["value"]);
expect(result).to.exist;
});
it("Should have all the right properties", () => {
const testName: string = "TEST-NAME";
const testParam: Parameter = new Parameter(testName, ["value1"]);
expect(testParam).to.have.property(
"paramName", "paramValues", "generate");
});
});
describe("GET Methods", () => {
describe("paramName", () => {
it("Should return the correct name", () => {
const testName: string = "TEST-NAME";
const testValues: string[] = ["value1", "value2"];
const testParam: Parameter = new Parameter(testName, testValues);
const result: string = testParam.paramName;
expect(result).to.equal(testName);
});
});
describe("paramValues", () => {
it("Should return the correct array of values", () => {
const testName: string = "TEST-NAME";
const testValues: string[] = ["value1", "value2"];
const testParam: Parameter = new Parameter(testName, testValues);
const result: string[] = testParam.paramValues;
expect(result).to.deep.equal(testValues);
});
});
});
describe("SET Methods", () => {
describe("paramName", () => {
it("Correctly sets iana-token names", () => {
});
it("Correctly sets x-name names", () => {
});
it("Throws an exception on incorrect name type", () => {
});
});
describe("paramValues", () => {
it("Correctly sets paramtext values", () => {
});
it("Correctly sets quoted-string values", () => {
});
it("Throws an exception on malformed string", () => {
});
});
});
describe("generate()", () => {
it("Correctly generates single-valued parameters", () => {
});
it("Correctly generates double-valued parameters", () => {
});
it("Correctly generates multi-valued parameters", () => {
});
});
describe("STATIC Methods", () => {
describe("isIanaToken()", () => {
it("exists", () => {
expect(Parameter).itself.respondsTo("isIanaToken");
});
it("returns true for valid iana-token", () => {
});
it("returns false for empty string", () => {
});
it("returns true for string containing \"-\"", () => {
});
it("returns false for string containing special chars", () => {
});
it("returns false for string containing control chars", () => {
});
});
describe("isXName()", () => {
it("exists", () => {
expect(Parameter).itself.respondsTo("isXName");
});
it("returns true for x-name value without vendorid", () => {
});
it("returns true for x-name value containing vendorid", () => {
});
it("returns false for x-name containing long vendorid", () => {
});
it("returns false for x-name containing special chars", () => {
});
it("returns false for x-name containing control chars", () => {
});
it("returns false when missing \"X-\" from start" +
" of x-name", () => {
});
it("returns false for empty string", () => {
});
it("returns false for vendorid containing special" +
" chars (even \"-\")", () => {
});
});
describe("isParamText()", () => {
it("exists", () => {
expect(Parameter).itself.respondsTo("isParamText");
});
it("returns ", () => {
});
});
describe("isSafeChar()", () => {
it("exists", () => {
expect(Parameter).itself.respondsTo("isSafeChar");
});
});
describe("isQuotedString()", () => {
it("exists", () => {
expect(Parameter).itself.respondsTo("isQuotedString");
});
});
describe("isQSafeChar()", () => {
it("exists", () => {
expect(Parameter).itself.respondsTo("isQSafeChar");
});
});
......
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