node/test/parallel/test-tty-wrap.js
Jeremiah Senkpiel 52bae222a3 test: abstract skip functionality to common
The tap skipping output is so prevalent yet obscure in nature that we
ought to move it into it's own function in test/common.js

PR-URL: https://github.com/nodejs/node/pull/6697
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2016-05-12 16:43:35 -04:00

29 lines
583 B
JavaScript

'use strict';
const common = require('../common');
var assert = require('assert');
var TTY = process.binding('tty_wrap').TTY;
var isTTY = process.binding('tty_wrap').isTTY;
if (isTTY(1) == false) {
common.skip('fd 1 is not a tty.');
return;
}
var handle = new TTY(1);
var callbacks = 0;
var req1 = handle.writeBuffer(Buffer.from('hello world\n'));
req1.oncomplete = function() {
callbacks++;
};
var req2 = handle.writeBuffer(Buffer.from('hello world\n'));
req2.oncomplete = function() {
callbacks++;
};
process.on('exit', function() {
assert.equal(2, callbacks);
});