Skip to content

Commit 20388c8

Browse files
committed
unit tests work
1 parent d6b428c commit 20388c8

File tree

7 files changed

+102
-112
lines changed

7 files changed

+102
-112
lines changed

javascript/json-transform/src/__tests__/functions/TransformerFunctionContains.test.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

javascript/json-transform/src/__tests__/functions/TransformerFunctionEval.test.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

javascript/json-transform/test/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createServer, type IncomingMessage, type ServerResponse } from "http";
44
import JsonTransformer from "../src/JsonTransformer";
55
import { HTMLHeaders, JSONHeaders, parseBody, send, JSONBig } from "./serverUtils";
66

7-
const PORT = 10001;
7+
const PORT = 10002;
88

99
process.on("uncaughtException", function (err) {
1010
console.info("Some unhandled error occurred");

test/src/assertTransformation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const JSONBig = {
2828
const hasOwn = Object.prototype.hasOwnProperty;
2929

3030
const PODS = {
31-
javascript: "http://localhost:10001/api/v1/transform",
31+
javascript: "http://localhost:10002/api/v1/transform",
3232
java: "http://localhost:10000/api/v1/transform"
3333
}
3434

test/tests/functions/eval.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[
2+
{
3+
"name": "inline",
4+
"given": {
5+
"input": {
6+
"a": 42,
7+
"b": "$.a"
8+
},
9+
"definition": "$$eval:$.b"
10+
},
11+
"expect": {
12+
"equal": 42
13+
}
14+
},
15+
{
16+
"name": "object - 1",
17+
"given": {
18+
"input": [
19+
{
20+
"value": 4
21+
},
22+
{
23+
"value": 2
24+
},
25+
{
26+
"value": 13.45
27+
},
28+
{
29+
}
30+
],
31+
"definition": {
32+
"$$eval": {
33+
"$$join": [
34+
"\\$",
35+
"$avg:",
36+
"\\$",
37+
"..value"
38+
]
39+
}
40+
}
41+
},
42+
"expect": {
43+
"equal": 6.483333333333333
44+
}
45+
},
46+
{
47+
"name": "object - 2",
48+
"given": {
49+
"input": [
50+
{
51+
"value": 4
52+
},
53+
{
54+
"value": 2
55+
},
56+
{
57+
"value": 13.45
58+
},
59+
{
60+
"value": null
61+
}
62+
],
63+
"definition": {
64+
"$$eval": {
65+
"$$jsonparse": "{\"$$avg\":\"$\", \"by\":\"##current.value\"}"
66+
}
67+
}
68+
},
69+
"expect": {
70+
"equal": 4.8625
71+
}
72+
}
73+
]

test/tests/transformations/jsonpath.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@
4747
]
4848
}
4949
},
50+
{
51+
"name": "Query indefinite path (descendent; 2)",
52+
"given": {
53+
"input": {
54+
"x": [
55+
{
56+
"a": 1
57+
},
58+
{
59+
"a": 2
60+
},
61+
{
62+
"a": null
63+
}
64+
]
65+
},
66+
"definition": "$..a"
67+
},
68+
"expect": {
69+
"equal": [
70+
1,
71+
2,
72+
null
73+
]
74+
}
75+
},
5076
{
5177
"name": "Query indefinite path (wildcard)",
5278
"given": {

test/tests/transformations/transformations.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
},
129129
{
130130
"name": "Spread - remove by hash null",
131+
"only": true,
131132
"given": {
132133
"input": {
133134
"a": "A",
@@ -144,24 +145,6 @@
144145
}
145146
}
146147
},
147-
{
148-
"name": "Spread - remove by null",
149-
"given": {
150-
"input": {
151-
"a": "A",
152-
"b": "B"
153-
},
154-
"definition": {
155-
"*": "$",
156-
"a": null
157-
}
158-
},
159-
"expect": {
160-
"equal": {
161-
"b": "B"
162-
}
163-
}
164-
},
165148
{
166149
"name": "Spread - as array",
167150
"given": {

0 commit comments

Comments
 (0)