• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5
6const stdoutWrite = process.stdout.write;
7
8// The sequence for moving the cursor to 0,0 and clearing screen down
9const check = '\u001b[1;1H\u001b[0J';
10
11function doTest(isTTY, check) {
12  let buf = '';
13  process.stdout.isTTY = isTTY;
14  process.stdout.write = (string) => buf += string;
15  console.clear();
16  process.stdout.write = stdoutWrite;
17  assert.strictEqual(buf, check);
18}
19
20// Fake TTY
21if (!common.isDumbTerminal) {
22  doTest(true, check);
23}
24doTest(false, '');
25