summaryrefslogtreecommitdiff
path: root/test/parallel/test-console-clear.js
blob: b6fc003165dc668e8b1c6929d082bab32acd8b20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';

require('../common');
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
doTest(true, check);
doTest(false, '');