Parameter.spec.ts 4.86 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 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 130 131 132 133 134 135 136 137 138 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
        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 \"-\")", () => {

            });
        });

164
        describe("isParamText()", () => {
165 166 167 168 169
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isParamText");
            });

            it("returns ", () => {
170

171
            });
172 173 174
        });

        describe("isSafeChar()", () => {
175 176 177 178
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isSafeChar");
            });

179 180 181 182

        });

        describe("isQuotedString()", () => {
183 184 185 186
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isQuotedString");
            });

187 188 189 190

        });

        describe("isQSafeChar()", () => {
191 192 193 194
            it("exists", () => {
                expect(Parameter).itself.respondsTo("isQSafeChar");
            });

195 196 197 198 199

        });

    });
});