|
| 1 | +import { expect } from 'chai'; |
| 2 | +import { isLetterChar, isLetterCharCode } from '../src/string-utils'; |
| 3 | + |
| 4 | +describe(`isLetterChar()`, () => { |
| 5 | + it(`when given letter characters A-Z and a-z, should return true`, () => { |
| 6 | + expect(isLetterChar('A')).to.equal(true); |
| 7 | + expect(isLetterChar('B')).to.equal(true); |
| 8 | + expect(isLetterChar('C')).to.equal(true); |
| 9 | + expect(isLetterChar('M')).to.equal(true); |
| 10 | + expect(isLetterChar('X')).to.equal(true); |
| 11 | + expect(isLetterChar('Y')).to.equal(true); |
| 12 | + expect(isLetterChar('Z')).to.equal(true); |
| 13 | + |
| 14 | + expect(isLetterChar('a')).to.equal(true); |
| 15 | + expect(isLetterChar('b')).to.equal(true); |
| 16 | + expect(isLetterChar('c')).to.equal(true); |
| 17 | + expect(isLetterChar('m')).to.equal(true); |
| 18 | + expect(isLetterChar('x')).to.equal(true); |
| 19 | + expect(isLetterChar('y')).to.equal(true); |
| 20 | + expect(isLetterChar('z')).to.equal(true); |
| 21 | + }); |
| 22 | + |
| 23 | + it(`when given non-letter characters (i.e. not A-Z or a-z), should return false`, () => { |
| 24 | + expect(isLetterChar('1')).to.equal(false); |
| 25 | + expect(isLetterChar('5')).to.equal(false); |
| 26 | + expect(isLetterChar('9')).to.equal(false); |
| 27 | + expect(isLetterChar('!')).to.equal(false); |
| 28 | + expect(isLetterChar('[')).to.equal(false); // char between the A-Z and a-z ASCII ranges |
| 29 | + expect(isLetterChar('_')).to.equal(false); // char between the A-Z and a-z ASCII ranges |
| 30 | + expect(isLetterChar('`')).to.equal(false); // char between the A-Z and a-z ASCII ranges |
| 31 | + expect(isLetterChar(' ')).to.equal(false); |
| 32 | + expect(isLetterChar('{')).to.equal(false); |
| 33 | + expect(isLetterChar('}')).to.equal(false); |
| 34 | + expect(isLetterChar(':')).to.equal(false); |
| 35 | + expect(isLetterChar(';')).to.equal(false); |
| 36 | + expect(isLetterChar('<')).to.equal(false); |
| 37 | + expect(isLetterChar('>')).to.equal(false); |
| 38 | + expect(isLetterChar('=')).to.equal(false); |
| 39 | + expect(isLetterChar('-')).to.equal(false); |
| 40 | + }); |
| 41 | +}); |
| 42 | + |
| 43 | +describe(`isLetterCharCodeCode()`, () => { |
| 44 | + it(`when given letter characters A-Z and a-z, should return true`, () => { |
| 45 | + expect(isLetterCharCode('A'.charCodeAt(0))).to.equal(true); |
| 46 | + expect(isLetterCharCode('B'.charCodeAt(0))).to.equal(true); |
| 47 | + expect(isLetterCharCode('C'.charCodeAt(0))).to.equal(true); |
| 48 | + expect(isLetterCharCode('M'.charCodeAt(0))).to.equal(true); |
| 49 | + expect(isLetterCharCode('X'.charCodeAt(0))).to.equal(true); |
| 50 | + expect(isLetterCharCode('Y'.charCodeAt(0))).to.equal(true); |
| 51 | + expect(isLetterCharCode('Z'.charCodeAt(0))).to.equal(true); |
| 52 | + |
| 53 | + expect(isLetterCharCode('a'.charCodeAt(0))).to.equal(true); |
| 54 | + expect(isLetterCharCode('b'.charCodeAt(0))).to.equal(true); |
| 55 | + expect(isLetterCharCode('c'.charCodeAt(0))).to.equal(true); |
| 56 | + expect(isLetterCharCode('m'.charCodeAt(0))).to.equal(true); |
| 57 | + expect(isLetterCharCode('x'.charCodeAt(0))).to.equal(true); |
| 58 | + expect(isLetterCharCode('y'.charCodeAt(0))).to.equal(true); |
| 59 | + expect(isLetterCharCode('z'.charCodeAt(0))).to.equal(true); |
| 60 | + }); |
| 61 | + |
| 62 | + it(`when given non-letter characters (i.e. not A-Z or a-z), should return false`, () => { |
| 63 | + expect(isLetterCharCode('1'.charCodeAt(0))).to.equal(false); |
| 64 | + expect(isLetterCharCode('5'.charCodeAt(0))).to.equal(false); |
| 65 | + expect(isLetterCharCode('9'.charCodeAt(0))).to.equal(false); |
| 66 | + expect(isLetterCharCode('!'.charCodeAt(0))).to.equal(false); |
| 67 | + expect(isLetterCharCode('['.charCodeAt(0))).to.equal(false); // char between the A-Z and a-z ASCII ranges |
| 68 | + expect(isLetterCharCode('_'.charCodeAt(0))).to.equal(false); // char between the A-Z and a-z ASCII ranges |
| 69 | + expect(isLetterCharCode('`'.charCodeAt(0))).to.equal(false); // char between the A-Z and a-z ASCII ranges |
| 70 | + expect(isLetterCharCode(' '.charCodeAt(0))).to.equal(false); |
| 71 | + expect(isLetterCharCode('{'.charCodeAt(0))).to.equal(false); |
| 72 | + expect(isLetterCharCode('}'.charCodeAt(0))).to.equal(false); |
| 73 | + expect(isLetterCharCode(':'.charCodeAt(0))).to.equal(false); |
| 74 | + expect(isLetterCharCode(';'.charCodeAt(0))).to.equal(false); |
| 75 | + expect(isLetterCharCode('<'.charCodeAt(0))).to.equal(false); |
| 76 | + expect(isLetterCharCode('>'.charCodeAt(0))).to.equal(false); |
| 77 | + expect(isLetterCharCode('='.charCodeAt(0))).to.equal(false); |
| 78 | + expect(isLetterCharCode('-'.charCodeAt(0))).to.equal(false); |
| 79 | + }); |
| 80 | +}); |
0 commit comments