@egodigital/egoose
Version:
Helper classes and functions for Node.js 10 or later.
80 lines • 3.42 kB
JavaScript
;
/**
* This file is part of the @egodigital/egoose distribution.
* Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/)
*
* @egodigital/egoose is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 3.
*
* @egodigital/egoose is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const mocha_1 = require("mocha");
const index_1 = require("../index");
mocha_1.describe('#toBooleanSafe()', function () {
mocha_1.describe('(null)', function () {
mocha_1.it('should return (false) when the value is (null)', function () {
const RES = index_1.toBooleanSafe(null);
assert.ok('boolean' === typeof RES);
assert.equal(RES, false);
assert.strictEqual(RES, false);
});
mocha_1.it('should return (true) when the value is (null)', function () {
const RES = index_1.toBooleanSafe(null, true);
assert.ok('boolean' === typeof RES);
assert.equal(RES, true);
assert.strictEqual(RES, true);
});
});
mocha_1.describe('(undefined)', function () {
mocha_1.it('should return (false) when the value is (null)', function () {
const RES = index_1.toBooleanSafe(undefined);
assert.ok('boolean' === typeof RES);
assert.equal(RES, false);
assert.strictEqual(RES, false);
});
mocha_1.it('should return (true) when the value is (null)', function () {
const RES = index_1.toBooleanSafe(undefined, true);
assert.ok('boolean' === typeof RES);
assert.equal(RES, true);
assert.strictEqual(RES, true);
});
});
mocha_1.describe('(true)', function () {
mocha_1.it('should return (true)', function () {
const RES = index_1.toBooleanSafe(true);
assert.ok('boolean' === typeof RES);
assert.equal(RES, true);
assert.strictEqual(RES, true);
});
mocha_1.it('should return (true)', function () {
const RES = index_1.toBooleanSafe(true, false);
assert.ok('boolean' === typeof RES);
assert.equal(RES, true);
assert.strictEqual(RES, true);
});
});
mocha_1.describe('(true)', function () {
mocha_1.it('should return (false)', function () {
const RES = index_1.toBooleanSafe(false);
assert.ok('boolean' === typeof RES);
assert.equal(RES, false);
assert.strictEqual(RES, false);
});
mocha_1.it('should return (false)', function () {
const RES = index_1.toBooleanSafe(false, true);
assert.ok('boolean' === typeof RES);
assert.equal(RES, false);
assert.strictEqual(RES, false);
});
});
});
//# sourceMappingURL=toBooleanSafe.js.map