11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// This test ensures that the escapeCodeTimeout option set correctly 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst readline = require('readline'); 81cb0ef41Sopenharmony_ciconst EventEmitter = require('events').EventEmitter; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciclass FakeInput extends EventEmitter { 111cb0ef41Sopenharmony_ci resume() {} 121cb0ef41Sopenharmony_ci pause() {} 131cb0ef41Sopenharmony_ci write() {} 141cb0ef41Sopenharmony_ci end() {} 151cb0ef41Sopenharmony_ci} 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci{ 181cb0ef41Sopenharmony_ci const fi = new FakeInput(); 191cb0ef41Sopenharmony_ci const rli = new readline.Interface({ 201cb0ef41Sopenharmony_ci input: fi, 211cb0ef41Sopenharmony_ci output: fi, 221cb0ef41Sopenharmony_ci escapeCodeTimeout: 50 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci assert.strictEqual(rli.escapeCodeTimeout, 50); 251cb0ef41Sopenharmony_ci rli.close(); 261cb0ef41Sopenharmony_ci} 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci[ 291cb0ef41Sopenharmony_ci null, 301cb0ef41Sopenharmony_ci {}, 311cb0ef41Sopenharmony_ci NaN, 321cb0ef41Sopenharmony_ci '50', 331cb0ef41Sopenharmony_ci].forEach((invalidInput) => { 341cb0ef41Sopenharmony_ci assert.throws(() => { 351cb0ef41Sopenharmony_ci const fi = new FakeInput(); 361cb0ef41Sopenharmony_ci const rli = new readline.Interface({ 371cb0ef41Sopenharmony_ci input: fi, 381cb0ef41Sopenharmony_ci output: fi, 391cb0ef41Sopenharmony_ci escapeCodeTimeout: invalidInput 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci rli.close(); 421cb0ef41Sopenharmony_ci }, { 431cb0ef41Sopenharmony_ci name: 'TypeError', 441cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_VALUE' 451cb0ef41Sopenharmony_ci }); 461cb0ef41Sopenharmony_ci}); 47