From 808e8ffa5df367902a19db8a753fcc8d029a3a8c Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Thu, 31 Oct 2024 11:45:08 +0000 Subject: [PATCH 1/2] fix: add TransformStream --- README.md | 1 + index.js | 1 + index.test.js | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index f6e4017..0576884 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ This project "fixes" the following global APIs, overriding whichever polyfills t - `URL` - `URLSearchParams` - `BroadcastChannel` +- `TransformStream` ## Getting started diff --git a/index.js b/index.js index b1f63d9..5251ae5 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,7 @@ class FixedJSDOMEnvironment extends JSDOMEnvironment { this.global.URLSearchParams = URLSearchParams this.global.BroadcastChannel = BroadcastChannel + this.global.TransformStream = TransformStream } } diff --git a/index.test.js b/index.test.js index 41cacc5..0bb2aa6 100644 --- a/index.test.js +++ b/index.test.js @@ -163,3 +163,9 @@ test('exposes "BroadcastChannel"', () => { expect(channel).toBeInstanceOf(BuiltinBroadcastChannel) channel.unref() }) + +test('exposes "TransformStream"', () => { + expect(globalThis).toHaveProperty('TransformStream') + const channel = new TransformStream() + expect(channel).toBeInstanceOf(TransformStream) +}) From e2fb15525555c25b48ce81590e5ba78b7a263cc9 Mon Sep 17 00:00:00 2001 From: Artem Zakharchenko Date: Sun, 3 Nov 2024 20:09:25 +0100 Subject: [PATCH 2/2] test: assert instance check against "node:stream/web" --- index.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.test.js b/index.test.js index 0bb2aa6..2d48f46 100644 --- a/index.test.js +++ b/index.test.js @@ -2,6 +2,7 @@ const { URL: BuiltinURL } = require('node:url') const { BroadcastChannel: BuiltinBroadcastChannel, } = require('node:worker_threads') +const { TransformStream: BuiltinTransformStream } = require('node:stream/web') test('exposes "Blob"', async () => { expect(globalThis).toHaveProperty('Blob') @@ -167,5 +168,5 @@ test('exposes "BroadcastChannel"', () => { test('exposes "TransformStream"', () => { expect(globalThis).toHaveProperty('TransformStream') const channel = new TransformStream() - expect(channel).toBeInstanceOf(TransformStream) + expect(channel).toBeInstanceOf(BuiltinTransformStream) })