Skip to content
Merged
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
test: reduce the use of private symbols in test-events-once.js
  • Loading branch information
kt3k committed Jun 12, 2025
commit 69252ed76db5b2a91a91374c718e87f97a745ab3
13 changes: 6 additions & 7 deletions test/parallel/test-events-once.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use strict';
// Flags: --expose-internals --no-warnings
// Flags: --no-warnings

const common = require('../common');
const { once, EventEmitter } = require('events');
const { once, EventEmitter, getEventListeners } = require('events');
const {
deepStrictEqual,
fail,
rejects,
strictEqual,
} = require('assert');
const { kEvents } = require('internal/event_target');

async function onceAnEvent() {
const ee = new EventEmitter();
Expand Down Expand Up @@ -78,7 +77,7 @@ async function catchesErrorsWithAbortSignal() {
try {
const promise = once(ee, 'myevent', { signal });
strictEqual(ee.listenerCount('error'), 1);
strictEqual(signal[kEvents].size, 1);
strictEqual(getEventListeners(signal, 'abort').length, 1);

await promise;
} catch (e) {
Expand All @@ -87,7 +86,7 @@ async function catchesErrorsWithAbortSignal() {
strictEqual(err, expected);
strictEqual(ee.listenerCount('error'), 0);
strictEqual(ee.listenerCount('myevent'), 0);
strictEqual(signal[kEvents].size, 0);
strictEqual(getEventListeners(signal, 'abort').length, 0);
}

async function stopListeningAfterCatchingError() {
Expand Down Expand Up @@ -198,9 +197,9 @@ async function abortSignalAfterEvent() {
ac.abort();
});
const promise = once(ee, 'foo', { signal: ac.signal });
strictEqual(ac.signal[kEvents].size, 1);
strictEqual(getEventListeners(ac.signal, 'abort').length, 1);
await promise;
strictEqual(ac.signal[kEvents].size, 0);
strictEqual(getEventListeners(ac.signal, 'abort').length, 0);
}

async function abortSignalRemoveListener() {
Expand Down