update dependencies and devDependencies, fix breaking changes from mystery-box update
[squeep-authentication-module] / test / lib / common.js
diff --git a/test/lib/common.js b/test/lib/common.js
new file mode 100644 (file)
index 0000000..921479c
--- /dev/null
@@ -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