xref: /third_party/node/test/parallel/test-console-clear.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst stdoutWrite = process.stdout.write;
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci// The sequence for moving the cursor to 0,0 and clearing screen down
91cb0ef41Sopenharmony_ciconst check = '\u001b[1;1H\u001b[0J';
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cifunction doTest(isTTY, check) {
121cb0ef41Sopenharmony_ci  let buf = '';
131cb0ef41Sopenharmony_ci  process.stdout.isTTY = isTTY;
141cb0ef41Sopenharmony_ci  process.stdout.write = (string) => buf += string;
151cb0ef41Sopenharmony_ci  console.clear();
161cb0ef41Sopenharmony_ci  process.stdout.write = stdoutWrite;
171cb0ef41Sopenharmony_ci  assert.strictEqual(buf, check);
181cb0ef41Sopenharmony_ci}
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci// Fake TTY
211cb0ef41Sopenharmony_ciif (!common.isDumbTerminal) {
221cb0ef41Sopenharmony_ci  doTest(true, check);
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_cidoTest(false, '');
25

Indexes created Thu Nov 07 10:32:03 CST 2024