| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | "use strict";var objectUtil = require('../../../src/server/util/object.util');var assert = require('assert');describe('Object utilities', function () {    describe('When test isJsonObject with "Array" object', function () {        it('should return false', function () {            assert.strictEqual(objectUtil.isJsonObject([]), false);        })    });    describe('When test isJsonObject with "Dict" object', function () {        it('should return true', function () {            assert.strictEqual(objectUtil.isJsonObject({age: 2}), true);        })    });    describe('When test fieldsCheck with full fields', function () {        it('should return false and missing fields.', function () {            var testing = objectUtil.fieldsCheck({                    from: 'Sand',                    to: 'Rose',                    data: 'Hello world.'                },                'from',                'to',                'data');            assert.strictEqual(true, testing.pass);        });    });    describe('When test fieldsCheck with missing fields', function () {        it('should return false and missing fields.', function () {            var testing = objectUtil.fieldsCheck({                    from: 'Sand',                    to: 'Rose',                    content: 'Hello world.'                },                'from',                'to',                'timestamp',                'expire',                'location');            assert.strictEqual(false, testing.pass);            assert.strictEqual(true, testing.message.indexOf('timestamp') > -1);            assert.strictEqual(true, testing.message.indexOf('expire') > -1);            assert.strictEqual(true, testing.message.indexOf('location') > -1);        });    });    describe('When test timestampToLong', function () {        it('should return 200.', function () {            var now = new Date(1479028394000);            var val = objectUtil.timestampToLong(now);            assert.strictEqual(1479028394000, val);        });    });});
 |