1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 | const assert = require("assert");
|
20 | const mocha_1 = require("mocha");
|
21 | const index_1 = require("../index");
|
22 | const WHITESPACES = " \t\r\n";
|
23 | mocha_1.describe('#normalizeString()', function () {
|
24 | mocha_1.describe('null', function () {
|
25 | mocha_1.it('should return empty string if input is (null)', function () {
|
26 | const RES = index_1.normalizeString(null);
|
27 | assert.ok('string' === typeof RES);
|
28 | assert.equal(RES, '');
|
29 | assert.strictEqual(RES, '');
|
30 | });
|
31 | });
|
32 | mocha_1.describe('undefined', function () {
|
33 | mocha_1.it('should return empty string if input is (undefined)', function () {
|
34 | const RES = index_1.normalizeString(undefined);
|
35 | assert.ok('string' === typeof RES);
|
36 | assert.equal(RES, '');
|
37 | assert.strictEqual(RES, '');
|
38 | });
|
39 | });
|
40 | mocha_1.describe('String', function () {
|
41 | mocha_1.it('should return empty string if input is an empty string', function () {
|
42 | const RES = index_1.normalizeString('');
|
43 | assert.ok('string' === typeof RES);
|
44 | assert.equal(RES, '');
|
45 | assert.strictEqual(RES, '');
|
46 | });
|
47 | mocha_1.it('should return empty string if input contains whitespaces only', function () {
|
48 | for (let i = 1; i <= 1000; i++) {
|
49 | let str = '';
|
50 | for (let j = 0; j < i; j++) {
|
51 | str += WHITESPACES[j % WHITESPACES.length];
|
52 | }
|
53 | const RES = index_1.normalizeString(str);
|
54 | assert.ok('string' === typeof RES);
|
55 | assert.equal(RES, '');
|
56 | assert.strictEqual(RES, '');
|
57 | }
|
58 | });
|
59 | mocha_1.it('should return lower case, trimmed version of an input string', function () {
|
60 | const RES = index_1.normalizeString(' Mk + tM ');
|
61 | assert.ok('string' === typeof RES);
|
62 | assert.equal(RES, 'mk + tm');
|
63 | assert.strictEqual(RES, 'mk + tm');
|
64 | });
|
65 | });
|
66 | mocha_1.describe('Number', function () {
|
67 | mocha_1.it('should return "0" if input is 0', function () {
|
68 | const RES = index_1.normalizeString(0);
|
69 | assert.ok('string' === typeof RES);
|
70 | assert.equal(RES, '0');
|
71 | assert.strictEqual(RES, '0');
|
72 | });
|
73 | });
|
74 | mocha_1.describe('Object', function () {
|
75 | mocha_1.it('should return empty string if #toString() of input returns empty string', function () {
|
76 | const RES = index_1.normalizeString({
|
77 | toString: () => '',
|
78 | });
|
79 | assert.ok('string' === typeof RES);
|
80 | assert.equal(RES, '');
|
81 | assert.strictEqual(RES, '');
|
82 | });
|
83 | mocha_1.it('should return empty string if #toString() of input contains whitespaces only', function () {
|
84 | for (let i = 1; i <= 1000; i++) {
|
85 | let str = '';
|
86 | for (let j = 0; j < i; j++) {
|
87 | str += WHITESPACES[j % WHITESPACES.length];
|
88 | }
|
89 | const RES = index_1.normalizeString({
|
90 | toString: () => str,
|
91 | });
|
92 | assert.ok('string' === typeof RES);
|
93 | assert.equal(RES, '');
|
94 | assert.strictEqual(RES, '');
|
95 | }
|
96 | });
|
97 | });
|
98 | });
|
99 |
|
\ | No newline at end of file |