Parameter.spec.ts 6.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import Parameter from "../src/Parameter";
import { expect } from "chai";
import "mocha";

/**
 * Test the Parameter parent class.
 */
describe("Parameter", () => {
    it("Should exist", () => {
        expect(Parameter).to.exist;
    });

    describe("constructor()", () => {
        it("Should create an object", () => {
15
            const result: Parameter = new Parameter("TestName", ["value"]);
16 17
            expect(result).to.exist;
        });
18 19 20 21 22 23 24 25

        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");
        });
26 27 28 29
    });

    describe("GET Methods", () => {
        describe("paramName", () => {
30 31 32 33 34 35 36 37
            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);
            });
38 39 40
        });

        describe("paramValues", () => {
41 42 43 44 45 46 47 48
            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);
            });
49 50 51 52 53
        });
    });

    describe("SET Methods", () => {
        describe("paramName", () => {
54 55 56 57 58
            it("Correctly sets iana-token names", () => {

            });

            it("Correctly sets x-name names", () => {
59

60 61 62 63 64
            });

            it("Throws an exception on incorrect name type", () => {

            });
65 66 67
        });

        describe("paramValues", () => {
68 69 70 71 72
            it("Correctly sets paramtext values", () => {

            });

            it("Correctly sets quoted-string values", () => {
73

74 75 76 77 78
            });

            it("Throws an exception on malformed string", () => {

            });
79 80 81 82
        });
    });

    describe("generate()", () => {
83 84 85 86 87 88 89
        it("Correctly generates single-valued parameters", () => {

        });

        it("Correctly generates double-valued parameters", () => {

        });
90

91 92 93
        it("Correctly generates multi-valued parameters", () => {

        });
94 95 96
    });

    describe("STATIC Methods", () => {
97 98 99 100 101 102
        /**
         * iana-token definition from RFC 5545 (pg. 10)
         *
         *     iana-token = 1*(ALPHA / DIGIT / "-")
         *     ; iCalendar identifier registered with IANA
         */
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
        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", () => {

            });

        });

130 131 132 133 134 135 136 137 138
        /**
         * x-name definition from RFC 5545 (pg. 10)
         *
         *     x-name = "X-" [vendorid "-"] 1*(ALPHA / DIGIT / "-")
         *     ; Reserved for experimental use.
         *
         *     vendorid = 3*(ALPHA / DIGIT)
         *     ; Vendor identification
         */
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
        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 \"-\")", () => {

            });
        });

179 180 181 182 183
        /**
         * param-text definition from RFC 5545 (pg. 10)
         *
         *     paramtext = *SAFE-CHAR
         */
184
        describe("isParamText()", () => {
185 186 187 188
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isParamText");
            });

189
            it("returns true for valid param text", () => {
190

191
            });
192 193
        });

194 195 196 197 198 199 200
        /**
         * SAFE-CHAR definition from RFC 5545 (pg. 11)
         *
         *     SAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-7E
         *               / NON-US-ASCII
         *     ; Any character except CONTROL, DQUOTE, ";", ":", ","
         */
201
        describe("isSafeChar()", () => {
202 203 204
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isSafeChar");
            });
205 206
        });

207 208 209 210 211
        /**
         * quoted-string definition from RFC 5545 (pg. 11)
         *
         *     quoted-string = DQUOTE *QSAFE-CHAR DQUOTE
         */
212
        describe("isQuotedString()", () => {
213 214 215
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isQuotedString");
            });
216 217
        });

218 219 220 221 222 223
        /**
         * QSAFE-CHAR definition from RFC 5545 (pg. 11)
         *
         *     QSAFE-CHAR = WSP / %x21 / %x23-7E / NON-US-ASCII
         *     ; Any character except CONTROL and DQUOTE
         */
224
        describe("isQSafeChar()", () => {
225 226 227
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isQSafeChar");
            });
228 229 230 231
        });

    });
});