remove now-unused function, consolidate remaining common functions
[squeep-mystery-box] / test / lib / mystery-box.js
index e949139aefb97c91c2dace523d5c268f4d28010b..510362bd06c8ab3a7884909e41404e0350d40494 100644 (file)
@@ -63,6 +63,23 @@ describe('MysteryBox', function () {
     });
   }); // constructor
 
+  describe('_ensureArray', function () {
+    it('returns empty array for no data', function () {
+      const result = MysteryBox._ensureArray();
+      assert.deepStrictEqual(result, []);
+    });
+    it('returns same array passed in', function () {
+      const expected = [1, 2, 3, 'foo'];
+      const result = MysteryBox._ensureArray(expected);
+      assert.deepStrictEqual(result, expected);
+    });
+    it('returns array containing non-array data', function () {
+      const data = 'bar';
+      const result = MysteryBox._ensureArray(data);
+      assert.deepStrictEqual(result, [data]);
+    });
+  }); // _ensureArray
+
   describe('_keyFromSecret', function () {
     it('covers invalid', async function () {
       assert.rejects(() => MysteryBox._keyFromSecret('unknown deriver', 'secret', 'salt', 32), MysteryBoxError);