Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ module.exports.Headers = require('./lib/web/fetch/headers').Headers
module.exports.Response = require('./lib/web/fetch/response').Response
module.exports.Request = require('./lib/web/fetch/request').Request

const { CloseEvent, ErrorEvent, MessageEvent } = require('./lib/web/websocket/events')
module.exports.WebSocket = require('./lib/web/websocket/websocket').WebSocket
module.exports.MessageEvent = require('./lib/web/websocket/events').MessageEvent
module.exports.CloseEvent = CloseEvent
module.exports.ErrorEvent = ErrorEvent
module.exports.MessageEvent = MessageEvent

module.exports.EventSource = require('./lib/web/eventsource/eventsource').EventSource

Expand Down
8 changes: 7 additions & 1 deletion test/fetch/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { test } = require('node:test')
const assert = require('node:assert')

const { Response, Request, FormData, Headers } = require('../../undici-fetch')
const { Response, Request, FormData, Headers, MessageEvent, CloseEvent, ErrorEvent } = require('../../undici-fetch')

test('bundle sets constructor.name and .name properly', () => {
assert.strictEqual(new Response().constructor.name, 'Response')
Expand Down Expand Up @@ -31,3 +31,9 @@ test('regression test for https://github.com/nodejs/node/issues/50263', () => {

assert.strictEqual(request1.headers.get('test'), 'abc')
})

test('WebSocket related events are exported', (t) => {
assert.deepStrictEqual(typeof CloseEvent, 'function')
assert.deepStrictEqual(typeof MessageEvent, 'function')
assert.deepStrictEqual(typeof ErrorEvent, 'function')
})