From 693589f2ca2b4ec746244f17a11d854c2b3367ac Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 13 Aug 2023 02:14:03 +0100 Subject: [PATCH] Add test for `getStreamAsBuffer()` when `Buffer` is not available --- test/buffer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/buffer.js b/test/buffer.js index 9ea0fac..cb7d1c2 100644 --- a/test/buffer.js +++ b/test/buffer.js @@ -83,3 +83,15 @@ test('getStreamAsBuffer() behaves like buffer()', async t => { ]); t.deepEqual(nativeResult, customResult); }); + +/* eslint-disable n/prefer-global/buffer */ +test('getStreamAsBuffer() only works in Node', async t => { + const {Buffer} = globalThis; + delete globalThis.Buffer; + try { + await t.throwsAsync(setupBuffer([fixtureString]), {message: /only supported in Node/}); + } finally { + globalThis.Buffer = Buffer; + } +}); +/* eslint-enable n/prefer-global/buffer */