Add basic test coverage of toArrayBuffer function

This commit is contained in:
Daniel Reichert 2014-11-19 23:23:43 -08:00 committed by lilia
parent 7f04439b37
commit 6125f7cbbb
1 changed files with 17 additions and 0 deletions

View File

@ -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/);
});
});
});