|
1 | 1 | const { URL: BuiltinURL } = require('node:url') |
| 2 | +const { |
| 3 | + BroadcastChannel: BuiltinBroadcastChannel, |
| 4 | +} = require('node:worker_threads') |
2 | 5 |
|
3 | 6 | test('exposes "Blob"', async () => { |
4 | 7 | expect(globalThis).toHaveProperty('Blob') |
@@ -38,7 +41,9 @@ test('exposes "TextEncoderStream"', async () => { |
38 | 41 | if (done) break |
39 | 42 | chunks.push(...value) |
40 | 43 | } |
41 | | - expect(Buffer.from(chunks)).toEqual(Buffer.from(new Uint8Array([104, 101, 108, 108, 111]))) |
| 44 | + expect(Buffer.from(chunks)).toEqual( |
| 45 | + Buffer.from(new Uint8Array([104, 101, 108, 108, 111])), |
| 46 | + ) |
42 | 47 | }) |
43 | 48 |
|
44 | 49 | test('exposes "TextDecoderStream"', async () => { |
@@ -139,6 +144,22 @@ test('exposes "URLSearchParams" and makes it mockable', () => { |
139 | 144 | .mockImplementation((key) => key === 'mocked_flag') |
140 | 145 |
|
141 | 146 | expect(globalThis).toHaveProperty('URLSearchParams') |
142 | | - expect(new URL('http://localhost?other_non_mocked_flag').searchParams.has('other_non_mocked_flag')).toBe(false) |
143 | | - expect(new URL('http://localhost?other_non_mocked_flag').searchParams.has('mocked_flag')).toBe(true) |
| 147 | + expect( |
| 148 | + new URL('http://localhost?other_non_mocked_flag').searchParams.has( |
| 149 | + 'other_non_mocked_flag', |
| 150 | + ), |
| 151 | + ).toBe(false) |
| 152 | + expect( |
| 153 | + new URL('http://localhost?other_non_mocked_flag').searchParams.has( |
| 154 | + 'mocked_flag', |
| 155 | + ), |
| 156 | + ).toBe(true) |
| 157 | +}) |
| 158 | + |
| 159 | +test('exposes "BroadcastChannel"', () => { |
| 160 | + expect(globalThis).toHaveProperty('BroadcastChannel') |
| 161 | + |
| 162 | + const channel = new BroadcastChannel('foo') |
| 163 | + expect(channel).toBeInstanceOf(BuiltinBroadcastChannel) |
| 164 | + channel.unref() |
144 | 165 | }) |
0 commit comments