Skip to content

Commit c39d570

Browse files
kt3ktargos
authored andcommitted
test: reduce the use of private symbols in test-events-once.js
PR-URL: #58685 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent b7e488c commit c39d570

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/parallel/test-events-once.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'use strict';
2-
// Flags: --expose-internals --no-warnings
2+
// Flags: --no-warnings
33

44
const common = require('../common');
5-
const { once, EventEmitter } = require('events');
5+
const { once, EventEmitter, getEventListeners } = require('events');
66
const {
77
deepStrictEqual,
88
fail,
99
rejects,
1010
strictEqual,
1111
} = require('assert');
12-
const { kEvents } = require('internal/event_target');
1312

1413
async function onceAnEvent() {
1514
const ee = new EventEmitter();
@@ -78,7 +77,7 @@ async function catchesErrorsWithAbortSignal() {
7877
try {
7978
const promise = once(ee, 'myevent', { signal });
8079
strictEqual(ee.listenerCount('error'), 1);
81-
strictEqual(signal[kEvents].size, 1);
80+
strictEqual(getEventListeners(signal, 'abort').length, 1);
8281

8382
await promise;
8483
} catch (e) {
@@ -87,7 +86,7 @@ async function catchesErrorsWithAbortSignal() {
8786
strictEqual(err, expected);
8887
strictEqual(ee.listenerCount('error'), 0);
8988
strictEqual(ee.listenerCount('myevent'), 0);
90-
strictEqual(signal[kEvents].size, 0);
89+
strictEqual(getEventListeners(signal, 'abort').length, 0);
9190
}
9291

9392
async function stopListeningAfterCatchingError() {
@@ -198,9 +197,9 @@ async function abortSignalAfterEvent() {
198197
ac.abort();
199198
});
200199
const promise = once(ee, 'foo', { signal: ac.signal });
201-
strictEqual(ac.signal[kEvents].size, 1);
200+
strictEqual(getEventListeners(ac.signal, 'abort').length, 1);
202201
await promise;
203-
strictEqual(ac.signal[kEvents].size, 0);
202+
strictEqual(getEventListeners(ac.signal, 'abort').length, 0);
204203
}
205204

206205
async function abortSignalRemoveListener() {

0 commit comments

Comments
 (0)