Skip to content

Commit

Permalink
unit tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
elisherer committed Nov 13, 2024
1 parent d6b428c commit 20388c8
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 112 deletions.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion javascript/json-transform/test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createServer, type IncomingMessage, type ServerResponse } from "http";
import JsonTransformer from "../src/JsonTransformer";
import { HTMLHeaders, JSONHeaders, parseBody, send, JSONBig } from "./serverUtils";

const PORT = 10001;
const PORT = 10002;

process.on("uncaughtException", function (err) {
console.info("Some unhandled error occurred");
Expand Down
2 changes: 1 addition & 1 deletion test/src/assertTransformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const JSONBig = {
const hasOwn = Object.prototype.hasOwnProperty;

const PODS = {
javascript: "http://localhost:10001/api/v1/transform",
javascript: "http://localhost:10002/api/v1/transform",
java: "http://localhost:10000/api/v1/transform"
}

Expand Down
73 changes: 73 additions & 0 deletions test/tests/functions/eval.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[
{
"name": "inline",
"given": {
"input": {
"a": 42,
"b": "$.a"
},
"definition": "$$eval:$.b"
},
"expect": {
"equal": 42
}
},
{
"name": "object - 1",
"given": {
"input": [
{
"value": 4
},
{
"value": 2
},
{
"value": 13.45
},
{
}
],
"definition": {
"$$eval": {
"$$join": [
"\\$",
"$avg:",
"\\$",
"..value"
]
}
}
},
"expect": {
"equal": 6.483333333333333
}
},
{
"name": "object - 2",
"given": {
"input": [
{
"value": 4
},
{
"value": 2
},
{
"value": 13.45
},
{
"value": null
}
],
"definition": {
"$$eval": {
"$$jsonparse": "{\"$$avg\":\"$\", \"by\":\"##current.value\"}"
}
}
},
"expect": {
"equal": 4.8625
}
}
]
26 changes: 26 additions & 0 deletions test/tests/transformations/jsonpath.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@
]
}
},
{
"name": "Query indefinite path (descendent; 2)",
"given": {
"input": {
"x": [
{
"a": 1
},
{
"a": 2
},
{
"a": null
}
]
},
"definition": "$..a"
},
"expect": {
"equal": [
1,
2,
null
]
}
},
{
"name": "Query indefinite path (wildcard)",
"given": {
Expand Down
19 changes: 1 addition & 18 deletions test/tests/transformations/transformations.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
},
{
"name": "Spread - remove by hash null",
"only": true,
"given": {
"input": {
"a": "A",
Expand All @@ -144,24 +145,6 @@
}
}
},
{
"name": "Spread - remove by null",
"given": {
"input": {
"a": "A",
"b": "B"
},
"definition": {
"*": "$",
"a": null
}
},
"expect": {
"equal": {
"b": "B"
}
}
},
{
"name": "Spread - as array",
"given": {
Expand Down

0 comments on commit 20388c8

Please sign in to comment.