UNPKG

4.09 kBJavaScriptView Raw
1"use strict";
2/**
3 * This file is part of the @egodigital/egoose distribution.
4 * Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/)
5 *
6 * @egodigital/egoose is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, version 3.
9 *
10 * @egodigital/egoose is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18Object.defineProperty(exports, "__esModule", { value: true });
19const assert = require("assert");
20const mocha_1 = require("mocha");
21const index_1 = require("../index");
22const WHITESPACES = " \t\r\n";
23mocha_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//# sourceMappingURL=isEmptyString.js.map
\No newline at end of file