2017-04-26 19:42:18 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-04-30 10:42:34 +00:00
|
|
|
const common = require('../common');
|
2017-04-26 19:42:18 +00:00
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const stdoutWrite = process.stdout.write;
|
|
|
|
|
|
|
|
// The sequence for moving the cursor to 0,0 and clearing screen down
|
|
|
|
const check = '\u001b[1;1H\u001b[0J';
|
|
|
|
|
|
|
|
function doTest(isTTY, check) {
|
|
|
|
let buf = '';
|
|
|
|
process.stdout.isTTY = isTTY;
|
|
|
|
process.stdout.write = (string) => buf += string;
|
|
|
|
console.clear();
|
|
|
|
process.stdout.write = stdoutWrite;
|
|
|
|
assert.strictEqual(buf, check);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fake TTY
|
2020-04-30 10:42:34 +00:00
|
|
|
if (!common.isDumbTerminal) {
|
|
|
|
doTest(true, check);
|
|
|
|
}
|
2017-04-26 19:42:18 +00:00
|
|
|
doTest(false, '');
|