util.spec.ts 1.47 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
        it("Should return false for numbers", () => {
19
20
            const test = "12345";
            const result = isAlpha(test);
21
22
23
24
25

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

        it("Should return false for alpha numerics", () => {
26
27
            const test = "a2a";
            const result = isAlpha(test);
28
29
30
31

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

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

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

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

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

        it("Should return true for uppercase alpha", () => {
47
48
            const test = "ABCDEF";
            const result = isAlpha(test);
49

50
            expect(result).to.be.true;
51
52
53
        });

        it("Should return true for mixed alpha", () => {
54
55
            const test = "aBcDeF";
            const result = isAlpha(test);
56
57
58
59
60

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