From 94832f3ebc8449b05e619d628665605d113efe95 Mon Sep 17 00:00:00 2001 From: skywalker Date: Sat, 6 Jun 2026 20:36:37 +0800 Subject: [PATCH] consolidate AMF operation tests --- tests/operations/tests/AMF.mjs | 59 ++++++++++++++++++++++++++++ tests/operations/tests/AMFDecode.mjs | 54 ------------------------- 2 files changed, 59 insertions(+), 54 deletions(-) delete mode 100644 tests/operations/tests/AMFDecode.mjs diff --git a/tests/operations/tests/AMF.mjs b/tests/operations/tests/AMF.mjs index e98039ea..394aa629 100644 --- a/tests/operations/tests/AMF.mjs +++ b/tests/operations/tests/AMF.mjs @@ -97,4 +97,63 @@ TestRegister.addTests([ } ], }, + { + name: "AMF3 Encode/Decode: object string", + input: "{\"a\": \"test\"}", + expectedMatch: /"\$value": "a"[\s\S]*"\$value": "test"/, + recipeConfig: [ + { + op: "AMF Encode", + args: ["AMF3"] + }, + { + op: "AMF Decode", + args: ["AMF3"] + } + ], + }, + { + name: "AMF3 Decode: empty input error", + input: "", + expectedOutput: "Could not decode AMF3 data: input is empty.", + recipeConfig: [ + { + op: "AMF Decode", + args: ["AMF3"] + } + ], + }, + { + name: "AMF3 Decode: newline input error", + input: "\n", + expectedOutput: "Could not decode AMF3 data. The input may be invalid or incomplete.", + recipeConfig: [ + { + op: "AMF Decode", + args: ["AMF3"] + } + ], + }, + { + name: "AMF3 Decode: truncated object input error", + input: "\x0a\x13\x01\x03a\x05\x40\x08", + expectedOutput: "Could not decode AMF3 data. The input may be invalid or incomplete.", + recipeConfig: [ + { + op: "AMF Decode", + args: ["AMF3"] + } + ], + }, + { + name: "AMF3 Decode: truncated array input error", + input: "\x09\x13\x01\x03a\x05\x40\x08", + expectedOutput: "Could not decode AMF3 data. The input may be invalid or incomplete.", + recipeConfig: [ + { + op: "AMF Decode", + args: ["AMF3"] + } + ], + }, ]); diff --git a/tests/operations/tests/AMFDecode.mjs b/tests/operations/tests/AMFDecode.mjs deleted file mode 100644 index cbb7c289..00000000 --- a/tests/operations/tests/AMFDecode.mjs +++ /dev/null @@ -1,54 +0,0 @@ -/** - * AMF Decode tests. - * - * @copyright Crown Copyright 2026 - * @license Apache-2.0 - */ -import TestRegister from "../../lib/TestRegister.mjs"; - -TestRegister.addTests([ - { - name: "AMF3 Decode: empty input error", - input: "", - expectedOutput: "Could not decode AMF3 data: input is empty.", - recipeConfig: [ - { - op: "AMF Decode", - args: ["AMF3"] - } - ], - }, - { - name: "AMF3 Decode: newline input error", - input: "\n", - expectedOutput: "Could not decode AMF3 data. The input may be invalid or incomplete.", - recipeConfig: [ - { - op: "AMF Decode", - args: ["AMF3"] - } - ], - }, - { - name: "AMF3 Decode: truncated object input error", - input: "\x0a\x13\x01\x03a\x05\x40\x08", - expectedOutput: "Could not decode AMF3 data. The input may be invalid or incomplete.", - recipeConfig: [ - { - op: "AMF Decode", - args: ["AMF3"] - } - ], - }, - { - name: "AMF3 Decode: truncated array input error", - input: "\x09\x13\x01\x03a\x05\x40\x08", - expectedOutput: "Could not decode AMF3 data. The input may be invalid or incomplete.", - recipeConfig: [ - { - op: "AMF Decode", - args: ["AMF3"] - } - ], - }, -]);