1// Flags: --expose-internals --no-warnings 2'use strict'; 3 4require('../common'); 5 6const { internalBinding } = require('internal/test/binding'); 7const { TTY, isTTY } = internalBinding('tty_wrap'); 8const strictEqual = require('assert').strictEqual; 9 10strictEqual(isTTY(0), true, 'fd 0 is not a TTY'); 11 12const handle = new TTY(0); 13handle.readStart(); 14handle.onread = () => {}; 15 16function isHandleActive(handle) { 17 return process._getActiveHandles().some((active) => active === handle); 18} 19 20strictEqual(isHandleActive(handle), true, 'TTY handle not initially active'); 21 22handle.unref(); 23 24strictEqual(isHandleActive(handle), false, 'TTY handle active after unref()'); 25 26handle.ref(); 27 28strictEqual(isHandleActive(handle), true, 'TTY handle inactive after ref()'); 29 30handle.unref(); 31