diff --git a/test/helpers_test.js b/test/helpers_test.js index 2f54eb80..f6aae39f 100644 --- a/test/helpers_test.js +++ b/test/helpers_test.js @@ -27,4 +27,21 @@ describe("Helpers", function() { assert.equal(getString(b), "\x00\xff\x80"); }); }); + + describe("toArrayBuffer", function() { + it('returns undefined when passed undefined', function() { + assert.strictEqual(toArrayBuffer(undefined), undefined); + }); + it('returns ArrayBuffer when passed ArrayBuffer', function() { + var StaticArrayBufferProto = new ArrayBuffer().__proto__; + var anArrayBuffer = new ArrayBuffer(); + assert.strictEqual(toArrayBuffer(anArrayBuffer), anArrayBuffer); + }); + it('throws an error when passed a non Stringable thing', function() { + var madeUpObject = function() {}; + var notStringable = new madeUpObject(); + assert.throw(function() { toArrayBuffer(notStringable) }, + Error, /Tried to convert a non-stringable thing/); + }); + }); });