node/test/pseudo-tty/test-tty-isatty.js
Antoine du Hamel ec26b1c01a
tools: add lint rule to ensure assertions are reached
PR-URL: https://github.com/nodejs/node/pull/60125
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-10-07 12:40:05 +00:00

18 lines
804 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const { isatty } = require('tty');
assert.ok(isatty(0), 'stdin reported to not be a tty, but it is');
assert.ok(isatty(1), 'stdout reported to not be a tty, but it is');
assert.ok(isatty(2), 'stderr reported to not be a tty, but it is');
assert.ok(!isatty(-1), '-1 reported to be a tty, but it is not');
assert.ok(!isatty(55555), '55555 reported to be a tty, but it is not');
assert.ok(!isatty(2 ** 31), '2^31 reported to be a tty, but it is not');
assert.ok(!isatty(1.1), '1.1 reported to be a tty, but it is not');
assert.ok(!isatty('1'), '\'1\' reported to be a tty, but it is not');
assert.ok(!isatty({}), '{} reported to be a tty, but it is not');
assert.ok(!isatty(() => {}), '() => {} reported to be a tty, but it is not');