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