mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-26 09:46:17 -04:00
Merge pull request #1286 from ccarpo/master
Added a JSON to YAML and a YAML to JSON operation
This commit is contained in:
commit
e469f00fc7
5 changed files with 144 additions and 0 deletions
41
tests/operations/tests/JSONtoYAML.mjs
Normal file
41
tests/operations/tests/JSONtoYAML.mjs
Normal file
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* YAML tests.
|
||||
*
|
||||
* @author ccarpo [ccarpo@gmx.net]
|
||||
*
|
||||
* @copyright Crown Copyright 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
const EXAMPLE_YAML = `number: 3\nplain: string\nblock: |\n two\n lines`;
|
||||
const EXAMPLE_JSON = `{ "number": 3, "plain": "string" }`;
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "YAML to JSON",
|
||||
input: EXAMPLE_YAML,
|
||||
expectedOutput: JSON.stringify({
|
||||
"number": 3,
|
||||
"plain": "string",
|
||||
"block": "two\nlines\n"
|
||||
}, null, 4),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "YAML to JSON",
|
||||
args: [],
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to YAML",
|
||||
input: EXAMPLE_JSON,
|
||||
expectedOutput: `number: 3\nplain: string\n`,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to YAML",
|
||||
args: [],
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue