mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[node:event] Add captureRejectionSymbol
This commit is contained in:
@@ -32,6 +32,10 @@ inline void generateEventsSourceCode(JSC::JSGlobalObject *lexicalGlobalObject,
|
||||
exportValues.append(JSC::JSFunction::create(
|
||||
vm, lexicalGlobalObject, 0, MAKE_STATIC_STRING_IMPL("on"),
|
||||
Events_functionOn, ImplementationVisibility::Public));
|
||||
exportNames.append(
|
||||
JSC::Identifier::fromString(vm, "captureRejectionSymbol"_s));
|
||||
exportValues.append(Symbol::create(
|
||||
vm, vm.symbolRegistry().symbolForKey("nodejs.rejection"_s)));
|
||||
|
||||
JSFunction *eventEmitterModuleCJS =
|
||||
jsCast<JSFunction *>(WebCore::JSEventEmitter::getConstructor(
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { test, describe, expect } from "bun:test";
|
||||
import { test, describe, expect, it } from "bun:test";
|
||||
import fs from "node:fs";
|
||||
|
||||
// this is also testing that imports with default and named imports in the same statement work
|
||||
// our transpiler transform changes this to a var with import.meta.require
|
||||
import EventEmitter, { getEventListeners } from "node:events";
|
||||
import EventEmitter, {
|
||||
getEventListeners,
|
||||
captureRejectionSymbol,
|
||||
} from "node:events";
|
||||
|
||||
describe("EventEmitter", () => {
|
||||
it("captureRejectionSymbol", () => {
|
||||
expect(EventEmitter.captureRejectionSymbol).toBeDefined();
|
||||
expect(captureRejectionSymbol).toBeDefined();
|
||||
});
|
||||
test("getEventListeners", () => {
|
||||
expect(getEventListeners(new EventEmitter(), "hey").length).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user