cyberchef/tests/operations/tests/EscapeSmartCharacters.mjs

133 lines
3.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Escape Smart Characters tests
*
* @author HarelKatz [github.com/HarelKatz]
* @copyright Crown Copyright 2026
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "Escape Smart Characters: smart quotes and apostrophes",
"input": "“Hello,” she said, yes.",
"expectedOutput": "\"Hello,\" she said, 'yes.'",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: em dash, en dash and ellipsis",
"input": "page 13 — wait…",
"expectedOutput": "page 1-3 -- wait...",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: trademark symbols",
"input": "Foo© Bar® Baz™",
"expectedOutput": "Foo(c) Bar(r) Baz(tm)",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: arrows and guillemets",
"input": "← → ↔ ⇒ « »",
"expectedOutput": "<-- --> <-> ==> << >>",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: math and misc",
"input": "3 × 4 ÷ 2 = 6, ±0.5 • item",
"expectedOutput": "3 x 4 / 2 = 6, +/-0.5 * item",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: NBSP becomes regular space",
"input": "a bc",
"expectedOutput": "a b c",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: unmappable Include preserves char",
"input": "warning: ☣ hazard",
"expectedOutput": "warning: ☣ hazard",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: unmappable Remove drops char",
"input": "warning: ☣ hazard",
"expectedOutput": "warning: hazard",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Remove"]
}
]
},
{
"name": "Escape Smart Characters: unmappable Replace substitutes dot",
"input": "warning: ☣ hazard",
"expectedOutput": "warning: . hazard",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Replace with '.'"]
}
]
},
{
"name": "Escape Smart Characters: pure ASCII passes through",
"input": "hello world! 123",
"expectedOutput": "hello world! 123",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
},
{
"name": "Escape Smart Characters: empty input",
"input": "",
"expectedOutput": "",
"recipeConfig": [
{
"op": "Escape Smart Characters",
"args": ["Include"]
}
]
}
]);