From 881ca45e439e5ade01900961c2d8288e96526f74 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 9 Jan 2016 17:41:56 +0100 Subject: [PATCH] test: run typedarray-to-buffer only in browsers with typed array support --- test/typedarray-to-buffer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/typedarray-to-buffer.js b/test/typedarray-to-buffer.js index 3d02210..cdff18a 100644 --- a/test/typedarray-to-buffer.js +++ b/test/typedarray-to-buffer.js @@ -4,12 +4,12 @@ var toBuffer = require('typedarray-to-buffer') var test = require('tape') test('convert to buffer from Uint8Array', function (t) { - if (typeof Uint8Array !== 'undefined') { + if (B.TYPED_ARRAY_SUPPORT === true && typeof window !== 'undefined') { var arr = new Uint8Array([1, 2, 3]) arr = toBuffer(arr) t.deepEqual(arr, new B([1, 2, 3]), 'contents equal') - t.ok(Buffer.isBuffer(arr), 'is buffer') + t.ok(B.isBuffer(arr), 'is buffer') t.equal(arr.readUInt8(0), 1) t.equal(arr.readUInt8(1), 2) t.equal(arr.readUInt8(2), 3) @@ -20,12 +20,12 @@ test('convert to buffer from Uint8Array', function (t) { }) test('convert to buffer from another arrayview type (Uint32Array)', function (t) { - if (typeof Uint32Array !== 'undefined' && B.TYPED_ARRAY_SUPPORT !== false) { + if (B.TYPED_ARRAY_SUPPORT === true && typeof window !== 'undefined') { var arr = new Uint32Array([1, 2, 3]) arr = toBuffer(arr) t.deepEqual(arr, new B([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]), 'contents equal') - t.ok(Buffer.isBuffer(arr), 'is buffer') + t.ok(B.isBuffer(arr), 'is buffer') t.equal(arr.readUInt32LE(0), 1) t.equal(arr.readUInt32LE(4), 2) t.equal(arr.readUInt32LE(8), 3) @@ -37,12 +37,12 @@ test('convert to buffer from another arrayview type (Uint32Array)', function (t) }) test('convert to buffer from ArrayBuffer', function (t) { - if (typeof Uint32Array !== 'undefined' && B.TYPED_ARRAY_SUPPORT !== false) { + if (B.TYPED_ARRAY_SUPPORT === true && typeof window !== 'undefined') { var arr = new Uint32Array([1, 2, 3]).subarray(1, 2) arr = toBuffer(arr) t.deepEqual(arr, new B([2, 0, 0, 0]), 'contents equal') - t.ok(Buffer.isBuffer(arr), 'is buffer') + t.ok(B.isBuffer(arr), 'is buffer') t.equal(arr.readUInt32LE(0), 2) t.equal(arr instanceof Uint8Array, true) } else { -- 2.34.1