X-Git-Url: http://git.squeep.com/?p=squeep-mystery-box;a=blobdiff_plain;f=test%2Flib%2Fmystery-box.js;h=a6e69b91f25ae0553dee526649e9ae51e103ef14;hp=8d228e6e25d4a5044b99bb889036f7be38a93d48;hb=383899395bf599359d60337edb651af0592f82cb;hpb=6dbf84c8308199dc0ad0e601e0081aafbc72f681 diff --git a/test/lib/mystery-box.js b/test/lib/mystery-box.js index 8d228e6..a6e69b9 100644 --- a/test/lib/mystery-box.js +++ b/test/lib/mystery-box.js @@ -161,6 +161,26 @@ describe('MysteryBox', function () { const decryptedResult = await mb.unpack(encryptedResult); assert.deepStrictEqual(decryptedResult, object); }); + + it('handles undefined', async function () { + try { + await mb.unpack(); + assert.fail(noExpectedException); + } catch (e) { + assert(e instanceof RangeError, noExpectedException); + } + }); + + it('handles incomplete', async function () { + const encryptedResult = await mb.pack({ foo: 'bar' }); + try { + await mb.unpack(encryptedResult.slice(0, 6)); + assert.fail(noExpectedException); + } catch (e) { + assert(e instanceof RangeError, noExpectedException); + } + }); + }); // pack, unpack }); // MysteryBox \ No newline at end of file