support providing multiple secrets, always encrypt with first, attempt decryption...
[squeep-mystery-box] / test / lib / common.js
index f5df10c779e1054b0881d701e382f4164f53ab1d..ad93ea17304b126368f8ff486d87e466a2b91bdc 100644 (file)
@@ -19,45 +19,21 @@ describe('Common', function () {
     });
   }); // fileScope
 
-  describe('base64ToBase64URL', function () {
-    it('covers', function () {
-      const b64 = '/+==';
-      const expected = '_-';
-      const result = common.base64ToBase64URL(b64);
-      assert.strictEqual(result, expected);
-    });
-    it('covers empty', function () {
-      const result = common.base64ToBase64URL(undefined);
-      assert.strictEqual(result, undefined);
-    });
-  }); // base64ToBase64URL
-
-  describe('base64URLToBase64', function () {
-    it('covers', function () {
-      const b64url = '_-';
-      const expected = '/+==';
-      const result = common.base64URLToBase64(b64url);
-      assert.strictEqual(result, expected);
-    });
-    it('covers empty', function () {
-      const result = common.base64URLToBase64(undefined);
-      assert.strictEqual(result, undefined);
-    });
-  }); // base64URLToBase64
-
-  describe('base64RePad', function () {
-    it('covers', function () {
-      const b64short = 'af';
-      const expected = 'af==';
-      const result = common.base64RePad(b64short);
-      assert.strictEqual(result, expected);
-    });
-    it('covers padded', function () {
-      const b64 = 'afd4';
-      const expected = b64;
-      const result = common.base64RePad(b64);
-      assert.strictEqual(result, expected);
-    });
-  }); // base64RePad
+  describe('ensureArray', function () {
+    it('returns empty array for no data', function () {
+      const result = common.ensureArray();
+      assert.deepStrictEqual(result, []);
+    });
+    it('returns same array passed in', function () {
+      const expected = [1, 2, 3, 'foo'];
+      const result = common.ensureArray(expected);
+      assert.deepStrictEqual(result, expected);
+    });
+    it('returns array containing non-array data', function () {
+      const data = 'bar';
+      const result = common.ensureArray(data);
+      assert.deepStrictEqual(result, [data]);
+    });
+  }); // ensureArray
 
 }); // Common