Add more Operation tests

This commit is contained in:
GCHQDeveloper581 2026-03-02 12:28:21 +00:00
parent d21a9bc6aa
commit 25f101f71a
No known key found for this signature in database
GPG Key ID: 6222E059A3DF595C
2 changed files with 55 additions and 0 deletions

View File

@ -153,6 +153,7 @@ import "./tests/SIGABA.mjs";
import "./tests/SM2.mjs"; import "./tests/SM2.mjs";
import "./tests/SM4.mjs"; import "./tests/SM4.mjs";
// import "./tests/SplitColourChannels.mjs"; // Cannot test operations that use the File type yet // import "./tests/SplitColourChannels.mjs"; // Cannot test operations that use the File type yet
import "./tests/SQLBeautify.mjs";
import "./tests/StrUtils.mjs"; import "./tests/StrUtils.mjs";
import "./tests/StripIPv4Header.mjs"; import "./tests/StripIPv4Header.mjs";
import "./tests/StripTCPHeader.mjs"; import "./tests/StripTCPHeader.mjs";

View File

@ -0,0 +1,54 @@
/**
* SQLBeautify tests.
*
* @author GCHQDeveloper581
* @copyright Crown Copyright 2026
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "SQL Beautify - basic",
input: "SELECT MONTH, ID, RAIN_I, TEMP_F FROM STATS;",
expectedOutput:
`SELECT
MONTH,
ID,
RAIN_I,
TEMP_F
FROM
STATS;`,
recipeConfig: [
{
op: "SQL Beautify",
args: [" "],
},
],
},
{
name: "SQL Beautify - upsert",
input: "INSERT INTO Table1 SELECT * FROM (SELECT :Bind1 as Field1, :Bind2 as Field2, :id as id) as new_data ON DUPLICATE KEY UPDATE Field1 = new_data.Field1, Field2 = new_data.Field2;",
expectedOutput:
`INSERT INTO
Table1
SELECT
*
FROM
(
SELECT
:Bind1 as Field1,
:Bind2 as Field2,
:id as id
) as new_data
ON DUPLICATE KEY UPDATE
Field1 = new_data.Field1,
Field2 = new_data.Field2;`,
recipeConfig: [
{
op: "SQL Beautify",
args: [" "],
},
],
},
]);