Skip to content

test: reduce the use of private symbols in test-events-once.js #58685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
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
Loading