X-Git-Url: https://git.squeep.com/?p=squeep-authentication-module;a=blobdiff_plain;f=test%2Flib%2Fcommon.js;fp=test%2Flib%2Fcommon.js;h=921479ce839b49c1b569f958d501e52d701116f0;hp=0000000000000000000000000000000000000000;hb=392502c5cc0cb12cf3c00ecd06c5c69b3e00d7e3;hpb=ec28f878b0d51ba03a0302060eb86aa5c69646b7 diff --git a/test/lib/common.js b/test/lib/common.js new file mode 100644 index 0000000..921479c --- /dev/null +++ b/test/lib/common.js @@ -0,0 +1,64 @@ +/* eslint-env mocha */ +'use strict'; + +const assert = require('assert'); +const sinon = require('sinon'); +const stubLogger = require('../stub-logger'); +const common = require('../../lib/common'); + +describe('Common', function () { + + describe('freezeDeep', function () { + it('covers', function () { + const obj = { + value: true, + subObj: { + subValue: true, + }, + }; + common.freezeDeep(obj); + assert.throws(() => obj.value = false, TypeError); + assert.throws(() => obj.subObj.subValue = false, TypeError); + }); + }); // freezeDeep + + describe('omit', function () { + it('does the expected', function () { + const orig = { + foo: 'foo', + bar: 23, + quux: { squawk: true }, + zounds: false, + }; + const omitted = ['foo', 'quux']; + const expected = { + bar: 23, + zounds: false, + }; + const result = common.omit(orig, omitted); + assert.deepStrictEqual(result, expected); + }); + }); // omit + + describe('mysteryBoxLogger', function () { + let mbl; + beforeEach(function () { + stubLogger._reset(); + mbl = common.mysteryBoxLogger(stubLogger, 'test:scope'); + }); + afterEach(function () { + sinon.restore(); + }); + it('covers', function () { + const stat = { + packageName: 'fake-mystery-box', + packageVersion: '0.0.0', + method: 'pack', + data: 'exists', + }; + mbl(stat); + assert(stubLogger.debug.called); + }); + }); // mysteryBoxLogger + +}); // Common \ No newline at end of file