UNPKG

@arisan/data-api

Version:

The Universal Database API Gateway for CLIO's Modules

57 lines (48 loc) 2.29 kB
'use strict'; var _chai = require('chai'); var _Utils = require('./Utils'); //endregion //region T. Tests //region 1. Platform Libraries describe('Utils', () => { describe('isValidPublicIP', () => { it('should return Error if no argument', () => _chai.assert.deepEqual((0, _Utils.isValidPublicIP)(), new Error('No Public IP'))); it('should return Error if malformed public IP', () => _chai.assert.deepEqual((0, _Utils.isValidPublicIP)('www.example.com'), new Error('Malformed Public IP www.example.com'))); it('should return Error if out of range', () => _chai.assert.deepEqual((0, _Utils.isValidPublicIP)('192.168.1.1'), new Error('Public IP in Invalid Range 192.168.1.1'))); it('should return true', () => _chai.assert.equal((0, _Utils.isValidPublicIP)('8.8.8.8'), true)); }); describe('isValidStreamIndex', () => { it('should pass if 0', () => _chai.assert.equal(true, (0, _Utils.isValidStreamIndex)(0))); }); describe('stripUndefined', () => { const source = { field1: 'field1', field2: undefined }; it('should strip undefined', () => _chai.assert.deepEqual((0, _Utils.stripUndefined)(source), { field1: 'field1' })); }); describe('valueOf', () => { const source = { one: 'one', two: { one: 'two_one' }, 3: { one: '3_one' }, four: [{}, { one: 'four_1_one' }] }; it('should get value', () => _chai.assert.equal((0, _Utils.valueOf)(source, 'one'), 'one')); it('should get value', () => _chai.assert.equal((0, _Utils.valueOf)(source, 'two', 'one'), 'two_one')); it('should get value', () => _chai.assert.equal((0, _Utils.valueOf)(source, 3, 'one'), '3_one')); it('should get value', () => _chai.assert.equal((0, _Utils.valueOf)(source, 'four', 1, 'one'), 'four_1_one')); it('should not get value', () => _chai.assert.equal((0, _Utils.valueOf)(), undefined)); it('should not get value', () => _chai.assert.equal((0, _Utils.valueOf)(source, 3, 'two'), undefined)); }); }); //endregion //endregion //region 2. Project Libraries //# sourceMappingURL=Utils.spec.js.map