• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-internals --no-warnings
2'use strict';
3
4// See also test/parallel/test-handle-wrap-isrefed.js
5
6const common = require('../common');
7const strictEqual = require('assert').strictEqual;
8const ReadStream = require('tty').ReadStream;
9const tty = new ReadStream(0);
10const { internalBinding } = require('internal/test/binding');
11const isTTY = internalBinding('tty_wrap').isTTY;
12strictEqual(isTTY(0), true, 'tty_wrap: stdin is not a TTY');
13strictEqual(tty._handle.hasRef(),
14            true, 'tty_wrap: not initially refed');
15tty.unref();
16strictEqual(tty._handle.hasRef(),
17            false, 'tty_wrap: unref() ineffective');
18tty.ref();
19strictEqual(tty._handle.hasRef(),
20            true, 'tty_wrap: ref() ineffective');
21tty._handle.close(common.mustCall(() =>
22  strictEqual(tty._handle.hasRef(),
23              false, 'tty_wrap: not unrefed on close')));
24