mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 18:44:40 +00:00

Both are simple utility functions defined by the WHATWG console spec (https://console.spec.whatwg.org/). PR-URL: https://github.com/nodejs/node/pull/12678 Ref: https://github.com/nodejs/node/issues/12675 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
23 lines
502 B
JavaScript
23 lines
502 B
JavaScript
'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, '');
|