UNPKG

3.42 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");
22mocha_1.describe('#toBooleanSafe()', function () {
23 mocha_1.describe('(null)', function () {
24 mocha_1.it('should return (false) when the value is (null)', function () {
25 const RES = index_1.toBooleanSafe(null);
26 assert.ok('boolean' === typeof RES);
27 assert.equal(RES, false);
28 assert.strictEqual(RES, false);
29 });
30 mocha_1.it('should return (true) when the value is (null)', function () {
31 const RES = index_1.toBooleanSafe(null, true);
32 assert.ok('boolean' === typeof RES);
33 assert.equal(RES, true);
34 assert.strictEqual(RES, true);
35 });
36 });
37 mocha_1.describe('(undefined)', function () {
38 mocha_1.it('should return (false) when the value is (null)', function () {
39 const RES = index_1.toBooleanSafe(undefined);
40 assert.ok('boolean' === typeof RES);
41 assert.equal(RES, false);
42 assert.strictEqual(RES, false);
43 });
44 mocha_1.it('should return (true) when the value is (null)', function () {
45 const RES = index_1.toBooleanSafe(undefined, true);
46 assert.ok('boolean' === typeof RES);
47 assert.equal(RES, true);
48 assert.strictEqual(RES, true);
49 });
50 });
51 mocha_1.describe('(true)', function () {
52 mocha_1.it('should return (true)', function () {
53 const RES = index_1.toBooleanSafe(true);
54 assert.ok('boolean' === typeof RES);
55 assert.equal(RES, true);
56 assert.strictEqual(RES, true);
57 });
58 mocha_1.it('should return (true)', function () {
59 const RES = index_1.toBooleanSafe(true, false);
60 assert.ok('boolean' === typeof RES);
61 assert.equal(RES, true);
62 assert.strictEqual(RES, true);
63 });
64 });
65 mocha_1.describe('(true)', function () {
66 mocha_1.it('should return (false)', function () {
67 const RES = index_1.toBooleanSafe(false);
68 assert.ok('boolean' === typeof RES);
69 assert.equal(RES, false);
70 assert.strictEqual(RES, false);
71 });
72 mocha_1.it('should return (false)', function () {
73 const RES = index_1.toBooleanSafe(false, true);
74 assert.ok('boolean' === typeof RES);
75 assert.equal(RES, false);
76 assert.strictEqual(RES, false);
77 });
78 });
79});
80//# sourceMappingURL=toBooleanSafe.js.map
\No newline at end of file