util.spec.ts 1.45 KB
Newer Older
1 2 3 4 5 6
import { isAlpha } from "./util";
import { expect } from "chai";
import "mocha";

describe("util", () => {
    describe("isAlpha", () => {
7 8 9 10

        it("Should exist", () => {
            let result = true;

11
            if (typeof isAlpha === undefined) {
12 13 14
                result = false;
            }

15 16
            expect(result).to.be.true;
        });
17

18 19 20 21 22 23 24 25 26 27 28 29 30 31
        it("Should return false for numbers", () => {
            let test = "12345";
            let result = isAlpha(test);

            expect(result).to.be.false;
        });

        it("Should return false for alpha numerics", () => {
            let test = "a2a";
            let result = isAlpha(test);

            expect(result).to.be.false;
        });

32 33 34 35 36 37 38
        it("Should return false for non-alpha numerics", () => {
            let test = ".%3adsk)#";
            let result = isAlpha(test);

            expect(result).to.be.false;
        });

39 40 41 42 43 44 45 46 47 48 49
        it("Should return true for lowercase alpha", () => {
            let test = "abcdef";
            let result = isAlpha(test);

            expect(result).to.be.true;
        });

        it("Should return true for uppercase alpha", () => {
            let test = "ABCDEF";
            let result = isAlpha(test);

50
            expect(result).to.be.true;
51 52 53 54 55 56 57 58 59 60
        });

        it("Should return true for mixed alpha", () => {
            let test = "aBcDeF";
            let result = isAlpha(test);

            expect(result).to.be.true;
        });
    });
});