source: imaps-frontend/node_modules/array-buffer-byte-length/test/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 842 bytes
Line 
1'use strict';
2
3var test = require('tape');
4var forEach = require('for-each');
5var v = require('es-value-fixtures');
6var inspect = require('object-inspect');
7
8var byteLength = require('../');
9
10test('byteLength', function (t) {
11 forEach(v.objects.concat(v.primitives), function (nonAB) {
12 t.equal(byteLength(nonAB), NaN, inspect(nonAB) + ' is not an ArrayBuffer, and yields NaN');
13 });
14
15 t.test('ArrayBuffers', { skip: typeof ArrayBuffer !== 'function' }, function (st) {
16 var ab32 = new ArrayBuffer(32);
17 st.equal(byteLength(ab32), 32, 'works on an ArrayBuffer of length 32: ' + inspect(ab32));
18
19 var ab0 = new ArrayBuffer(0);
20 st.equal(byteLength(ab0), 0, 'works on an ArrayBuffer of length 0: ' + inspect(ab0));
21
22 var dv = new DataView(ab32);
23 st.equal(byteLength(dv), NaN, 'a DataView returns NaN');
24
25 st.end();
26 });
27
28 t.end();
29});
Note: See TracBrowser for help on using the repository browser.