Add remove ANSI escape codes operation (#2143)
Co-authored-by: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> (additional test case)
This commit is contained in:
co-authored by
GCHQDeveloper581
parent
89b5c7dee3
commit
72ca1aeec7
@@ -148,6 +148,7 @@ import "./tests/Rabbit.mjs";
|
||||
import "./tests/RAKE.mjs";
|
||||
import "./tests/Regex.mjs";
|
||||
import "./tests/Register.mjs";
|
||||
import "./tests/RemoveANSIEscapeCodes.mjs";
|
||||
import "./tests/RegularExpression.mjs";
|
||||
import "./tests/RenderMarkdown.mjs";
|
||||
import "./tests/RisonEncodeDecode.mjs";
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @author Louis-Ladd [lewisharshman1@gmail.com]
|
||||
* @copyright Crown Copyright 2025
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
"name": "Remove ANSI Escape Codes: text using x1b escape code",
|
||||
"input": "\x1b[31mHello, \x1b[31mWorld!",
|
||||
"expectedOutput": "Hello, World!",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "Remove ANSI Escape Codes",
|
||||
"args": [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Remove ANSI Escape Codes: text with incomplete codes",
|
||||
"input": "\x1b[31 Hello, World!",
|
||||
"expectedOutput": "ello, World!",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "Remove ANSI Escape Codes",
|
||||
"args": [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Remove ANSI Escape Codes: cursor commands and clear screen",
|
||||
"input": "\x1b[2J\x1b[H\x1b[3BHello, World!",
|
||||
"expectedOutput": "Hello, World!",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "Remove ANSI Escape Codes",
|
||||
"args": [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Remove ANSI Escape Codes: text containing javascript escape representation of ansi escape codes",
|
||||
// input/output expressed in hex to avoid accidental interpretation of Javascript escapes and to make the test case explicit
|
||||
"input": "5c 30 33 33 5b 33 32 3b 31 3b 33 3b 34 3b 39 6d 48 65 6c 6c 6f 2c 20 5c 30 33 33 5b 33 32 3b 31 3b 33 3b 34 3b 39 6d 57 6f 72 6c 64 21",
|
||||
"expectedOutput": "5c 30 33 33 5b 33 32 3b 31 3b 33 3b 34 3b 39 6d 48 65 6c 6c 6f 2c 20 5c 30 33 33 5b 33 32 3b 31 3b 33 3b 34 3b 39 6d 57 6f 72 6c 64 21",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Auto"]
|
||||
},
|
||||
{
|
||||
"op": "Remove ANSI Escape Codes",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"op": "To Hex",
|
||||
"args": ["Space", 0]
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
||||
Reference in New Issue
Block a user