jest-fixed-jsdom
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -9,2 +9,4 @@ const JSDOMEnvironment = require('jest-environment-jsdom').default | ||
this.global.TextEncoder = TextEncoder | ||
this.global.TextDecoderStream = TextDecoderStream | ||
this.global.TextEncoderStream = TextEncoderStream | ||
this.global.ReadableStream = ReadableStream | ||
@@ -11,0 +13,0 @@ |
@@ -25,2 +25,40 @@ const { URL: BuiltinURL } = require('node:url') | ||
test('exposes "TextEncoderStream"', async () => { | ||
expect(globalThis).toHaveProperty('TextEncoderStream') | ||
expect(() => new TextEncoderStream()).not.toThrow() | ||
const stream = new TextEncoderStream() | ||
const writer = stream.writable.getWriter() | ||
writer.write('hello') | ||
writer.close() | ||
const reader = stream.readable.getReader() | ||
const chunks = [] | ||
while (true) { | ||
const { done, value } = await reader.read() | ||
if (done) break | ||
chunks.push(...value) | ||
} | ||
expect(Buffer.from(chunks)).toEqual(Buffer.from(new Uint8Array([104, 101, 108, 108, 111]))) | ||
}) | ||
test('exposes "TextDecoderStream"', async () => { | ||
expect(globalThis).toHaveProperty('TextDecoderStream') | ||
expect(() => new TextDecoderStream()).not.toThrow() | ||
const stream = new TextDecoderStream() | ||
const writer = stream.writable.getWriter() | ||
writer.write(new Uint8Array([104, 101, 108, 108, 111])) | ||
writer.close() | ||
const reader = stream.readable.getReader() | ||
const chunks = [] | ||
while (true) { | ||
const { done, value } = await reader.read() | ||
if (done) break | ||
chunks.push(value) | ||
} | ||
expect(chunks.join('')).toBe('hello') | ||
}) | ||
test('exposes "ReadableStream"', () => { | ||
@@ -27,0 +65,0 @@ expect(globalThis).toHaveProperty('ReadableStream') |
{ | ||
"name": "jest-fixed-jsdom", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A superset of the JSDOM environment for Jest that respects Node.js globals.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -35,2 +35,4 @@ <h1 align="center">jest-fixed-jsdom</h1> | ||
- `TextDecoder` | ||
- `TextEncoderStream` | ||
- `TextDecoderStream` | ||
- `structuredClone()` | ||
@@ -37,0 +39,0 @@ - `URL` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9468
144
60