From eef8d55d86742a3fd46ddfc5540cebfcb2ec012e Mon Sep 17 00:00:00 2001 From: John Brick Date: Thu, 19 Mar 2026 13:10:35 +0300 Subject: [PATCH] fix(A1Z26): return empty string instead of empty array for empty input (#2257) --- src/core/operations/A1Z26CipherDecode.mjs | 2 +- tests/operations/index.mjs | 1 + tests/operations/tests/A1Z26CipherDecode.mjs | 33 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/operations/tests/A1Z26CipherDecode.mjs diff --git a/src/core/operations/A1Z26CipherDecode.mjs b/src/core/operations/A1Z26CipherDecode.mjs index 0b097c2b..cc9aafbf 100644 --- a/src/core/operations/A1Z26CipherDecode.mjs +++ b/src/core/operations/A1Z26CipherDecode.mjs @@ -76,7 +76,7 @@ class A1Z26CipherDecode extends Operation { const delim = Utils.charRep(args[0] || "Space"); if (input.length === 0) { - return []; + return ""; } const bites = input.split(delim); diff --git a/tests/operations/index.mjs b/tests/operations/index.mjs index fb03a5f7..3585e270 100644 --- a/tests/operations/index.mjs +++ b/tests/operations/index.mjs @@ -14,6 +14,7 @@ import { setLongTestFailure, logTestReport } from "../lib/utils.mjs"; import TestRegister from "../lib/TestRegister.mjs"; +import "./tests/A1Z26CipherDecode.mjs"; import "./tests/AESKeyWrap.mjs"; import "./tests/AlternatingCaps.mjs"; import "./tests/AvroToJSON.mjs"; diff --git a/tests/operations/tests/A1Z26CipherDecode.mjs b/tests/operations/tests/A1Z26CipherDecode.mjs new file mode 100644 index 00000000..97020e0b --- /dev/null +++ b/tests/operations/tests/A1Z26CipherDecode.mjs @@ -0,0 +1,33 @@ +/** + * A1Z26 Cipher Decode tests + * + * @author brick-pixel + * @copyright Crown Copyright 2026 + * @license Apache-2.0 + */ +import TestRegister from "../../lib/TestRegister.mjs"; + +TestRegister.addTests([ + { + "name": "A1Z26 Cipher Decode: basic decode", + "input": "8 5 12 12 15", + "expectedOutput": "hello", + "recipeConfig": [ + { + "op": "A1Z26 Cipher Decode", + "args": ["Space"] + } + ] + }, + { + "name": "A1Z26 Cipher Decode: empty input returns empty string", + "input": "", + "expectedOutput": "", + "recipeConfig": [ + { + "op": "A1Z26 Cipher Decode", + "args": ["Space"] + } + ] + } +]);