From 2a93c134dc93d70b5f6ea9d417c88207661884d5 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Wed, 20 Apr 2022 15:48:15 -0400 Subject: feat(repl): add global clear() function (#14332) This commit adds a clear() function in the REPL which works similar to console.clear(). --- cli/tests/integration/repl_tests.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cli/tests/integration/repl_tests.rs') diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index a63be3ece..05a17d4b7 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -761,3 +761,21 @@ fn eval_file_flag_multiple_files() { assert!(out.contains("helloFOO")); assert!(err.contains("Download")); } + +#[test] +fn pty_clear_function() { + util::with_pty(&["repl"], |mut console| { + console.write_line("console.log('hello');"); + console.write_line("clear();"); + console.write_line("const clear = 1 + 2;"); + console.write_line("clear;"); + console.write_line("close();"); + + let output = console.read_all_output(); + assert!(output.contains("hello")); + assert!(output.contains("[1;1H")); + assert!(output.contains("undefined")); + assert!(output.contains("const clear = 1 + 2;")); + assert!(output.contains('3')); + }); +} -- cgit v1.2.3