mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/60125 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
31 lines
720 B
JavaScript
31 lines
720 B
JavaScript
// Flags: --expose-internals --no-warnings
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { TTY, isTTY } = internalBinding('tty_wrap');
|
|
const assert = require('assert');
|
|
|
|
assert.ok(isTTY(0), 'fd 0 is not a TTY');
|
|
|
|
const handle = new TTY(0);
|
|
handle.readStart();
|
|
handle.onread = () => {};
|
|
|
|
function isHandleActive(handle) {
|
|
return process._getActiveHandles().some((active) => active === handle);
|
|
}
|
|
|
|
assert.ok(isHandleActive(handle), 'TTY handle not initially active');
|
|
|
|
handle.unref();
|
|
|
|
assert.ok(!isHandleActive(handle), 'TTY handle active after unref()');
|
|
|
|
handle.ref();
|
|
|
|
assert.ok(isHandleActive(handle), 'TTY handle inactive after ref()');
|
|
|
|
handle.unref();
|