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('#isEmptyString()', function () {
|
24 | mocha_1.describe('null', function () {
|
25 | mocha_1.it('should return (true) if input is (null)', function () {
|
26 | const RES = index_1.isEmptyString(null);
|
27 | assert.ok('boolean' === typeof RES);
|
28 | assert.ok(RES);
|
29 | assert.equal(RES, true);
|
30 | assert.strictEqual(RES, true);
|
31 | });
|
32 | });
|
33 | mocha_1.describe('undefined', function () {
|
34 | mocha_1.it('should return (true) if input is (undefined)', function () {
|
35 | const RES = index_1.isEmptyString(undefined);
|
36 | assert.ok('boolean' === typeof RES);
|
37 | assert.ok(RES);
|
38 | assert.equal(RES, true);
|
39 | assert.strictEqual(RES, true);
|
40 | });
|
41 | });
|
42 | mocha_1.describe('String', function () {
|
43 | mocha_1.it('should return (true) if input is an empty string', function () {
|
44 | const RES = index_1.isEmptyString('');
|
45 | assert.ok('boolean' === typeof RES);
|
46 | assert.ok(RES);
|
47 | assert.equal(RES, true);
|
48 | assert.strictEqual(RES, true);
|
49 | });
|
50 | mocha_1.it('should return (true) if input contains whitespaces only', function () {
|
51 | for (let i = 1; i <= 1000; i++) {
|
52 | let str = '';
|
53 | for (let j = 0; j < i; j++) {
|
54 | str += WHITESPACES[j % WHITESPACES.length];
|
55 | }
|
56 | const RES = index_1.isEmptyString(str);
|
57 | assert.ok('boolean' === typeof RES);
|
58 | assert.ok(RES);
|
59 | assert.equal(RES, true);
|
60 | assert.strictEqual(RES, true);
|
61 | }
|
62 | });
|
63 | });
|
64 | mocha_1.describe('Number', function () {
|
65 | mocha_1.it('should return (false) if input is 0', function () {
|
66 | const RES = index_1.isEmptyString(0);
|
67 | assert.ok('boolean' === typeof RES);
|
68 | assert.ok(!RES);
|
69 | assert.equal(RES, false);
|
70 | assert.strictEqual(RES, false);
|
71 | });
|
72 | });
|
73 | mocha_1.describe('Object', function () {
|
74 | mocha_1.it('should return (true) if #toString() of input returns empty string', function () {
|
75 | const RES = index_1.isEmptyString({
|
76 | toString: () => '',
|
77 | });
|
78 | assert.ok('boolean' === typeof RES);
|
79 | assert.ok(RES);
|
80 | assert.equal(RES, true);
|
81 | assert.strictEqual(RES, true);
|
82 | });
|
83 | mocha_1.it('should return (true) if #toString() of input returns 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.isEmptyString({
|
90 | toString: () => str,
|
91 | });
|
92 | assert.ok('boolean' === typeof RES);
|
93 | assert.ok(RES);
|
94 | assert.equal(RES, true);
|
95 | assert.strictEqual(RES, true);
|
96 | }
|
97 | });
|
98 | });
|
99 | });
|
100 |
|
\ | No newline at end of file |