It’s not necessary to assert that the internal `hasRef()` method exists, since it is always called directly afterwards in these tests. Furthermore, the test is overly specific, in that it expects them on a specific position in the prototype chain. PR-URL: https://github.com/nodejs/node/pull/23040 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
23 lines
865 B
JavaScript
23 lines
865 B
JavaScript
// Flags: --expose-internals --no-warnings
|
|
'use strict';
|
|
|
|
// see also test/parallel/test-handle-wrap-isrefed.js
|
|
|
|
const common = require('../common');
|
|
const strictEqual = require('assert').strictEqual;
|
|
const ReadStream = require('tty').ReadStream;
|
|
const tty = new ReadStream(0);
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const isTTY = internalBinding('tty_wrap').isTTY;
|
|
strictEqual(isTTY(0), true, 'tty_wrap: stdin is not a TTY');
|
|
strictEqual(tty._handle.hasRef(),
|
|
true, 'tty_wrap: not initially refed');
|
|
tty.unref();
|
|
strictEqual(tty._handle.hasRef(),
|
|
false, 'tty_wrap: unref() ineffective');
|
|
tty.ref();
|
|
strictEqual(tty._handle.hasRef(),
|
|
true, 'tty_wrap: ref() ineffective');
|
|
tty._handle.close(common.mustCall(() =>
|
|
strictEqual(tty._handle.hasRef(),
|
|
false, 'tty_wrap: not unrefed on close')));
|