mirror of
https://github.com/gorules/zen.git
synced 2026-10-05 16:02:40 +00:00
add tests
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"extra": "This should not pass through"
|
||||
},
|
||||
"output": {
|
||||
"sum": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 5,
|
||||
"b": 3,
|
||||
"sum": 100
|
||||
},
|
||||
"output": {
|
||||
"sum": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 10,
|
||||
"b": 20,
|
||||
"c": 30,
|
||||
"d": 40
|
||||
},
|
||||
"output": {
|
||||
"sum": 30
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 7,
|
||||
"b": 3,
|
||||
"passThrough": "This should not appear in output"
|
||||
},
|
||||
"output": {
|
||||
"sum": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": -5,
|
||||
"b": 5,
|
||||
"negative": true
|
||||
},
|
||||
"output": {
|
||||
"sum": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"type": "inputNode",
|
||||
"id": "deced339-bace-452a-8db0-777f038bffe8",
|
||||
"name": "request",
|
||||
"position": {
|
||||
"x": 145,
|
||||
"y": 235
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "expressionNode",
|
||||
"content": {
|
||||
"expressions": [
|
||||
{
|
||||
"id": "d54641c2-5f24-4140-a9c4-8453542a622a",
|
||||
"key": "sum",
|
||||
"value": "a + b"
|
||||
}
|
||||
],
|
||||
"passThrough": false
|
||||
},
|
||||
"id": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770",
|
||||
"name": "expression1",
|
||||
"position": {
|
||||
"x": 475,
|
||||
"y": 235
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "639f3a3a-7545-4e98-aa79-7a9bd9644af1",
|
||||
"sourceId": "deced339-bace-452a-8db0-777f038bffe8",
|
||||
"type": "edge",
|
||||
"targetId": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"customer": {
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"age": 30
|
||||
},
|
||||
"order": {
|
||||
"id": "ORD-001",
|
||||
"total": 100
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"customer": {
|
||||
"firstName": "John",
|
||||
"lastName": "Doe",
|
||||
"age": 30,
|
||||
"fullName": "John Doe"
|
||||
},
|
||||
"order": {
|
||||
"id": "ORD-001",
|
||||
"total": 100
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"customer": {
|
||||
"firstName": "Jane",
|
||||
"lastName": "Smith",
|
||||
"age": 25
|
||||
},
|
||||
"order": {
|
||||
"id": "ORD-002",
|
||||
"total": 150
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"customer": {
|
||||
"firstName": "Jane",
|
||||
"lastName": "Smith",
|
||||
"age": 25,
|
||||
"fullName": "Jane Smith"
|
||||
},
|
||||
"order": {
|
||||
"id": "ORD-002",
|
||||
"total": 150
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"type": "inputNode",
|
||||
"id": "input-node",
|
||||
"name": "request",
|
||||
"position": {
|
||||
"x": 100,
|
||||
"y": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "expressionNode",
|
||||
"id": "expression-node-1",
|
||||
"name": "customerFullName",
|
||||
"position": {
|
||||
"x": 300,
|
||||
"y": 100
|
||||
},
|
||||
"content": {
|
||||
"inputField": "customer",
|
||||
"outputPath": "customer",
|
||||
"expressions": [
|
||||
{
|
||||
"id": "07795ded-cb9b-4165-9b5e-783b066dda61",
|
||||
"key": "fullName",
|
||||
"value": "`${firstName} ${lastName}`"
|
||||
}
|
||||
],
|
||||
"passThrough": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "edge-1",
|
||||
"sourceId": "input-node",
|
||||
"targetId": "expression-node-1",
|
||||
"type": "edge"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"cart": {
|
||||
"items": [
|
||||
{
|
||||
"name": "Apple",
|
||||
"price": 0.5,
|
||||
"quantity": 3
|
||||
},
|
||||
{
|
||||
"name": "Banana",
|
||||
"price": 0.3,
|
||||
"quantity": 5
|
||||
},
|
||||
{
|
||||
"name": "Orange",
|
||||
"price": 0.7,
|
||||
"quantity": 2
|
||||
}
|
||||
],
|
||||
"customerId": "CUST-001"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"cart": {
|
||||
"items": [
|
||||
{
|
||||
"name": "Apple",
|
||||
"price": 0.5,
|
||||
"quantity": 3,
|
||||
"totalPrice": 1.5
|
||||
},
|
||||
{
|
||||
"name": "Banana",
|
||||
"price": 0.3,
|
||||
"quantity": 5,
|
||||
"totalPrice": 1.5
|
||||
},
|
||||
{
|
||||
"name": "Orange",
|
||||
"price": 0.7,
|
||||
"quantity": 2,
|
||||
"totalPrice": 1.4
|
||||
}
|
||||
],
|
||||
"customerId": "CUST-001"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"type": "inputNode",
|
||||
"id": "input-node",
|
||||
"name": "request",
|
||||
"position": {
|
||||
"x": 100,
|
||||
"y": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "expressionNode",
|
||||
"id": "expression-node-1",
|
||||
"name": "calculateItemTotal",
|
||||
"position": {
|
||||
"x": 300,
|
||||
"y": 100
|
||||
},
|
||||
"content": {
|
||||
"inputField": "cart.items",
|
||||
"outputPath": "cart.items",
|
||||
"executionMode": "loop",
|
||||
"expressions": [
|
||||
{
|
||||
"id": "total-price-exp",
|
||||
"key": "totalPrice",
|
||||
"value": "price * quantity"
|
||||
}
|
||||
],
|
||||
"passThrough": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "edge-1",
|
||||
"sourceId": "input-node",
|
||||
"targetId": "expression-node-1",
|
||||
"type": "edge"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"sum": []
|
||||
},
|
||||
"output": {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"sum": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 5,
|
||||
"b": 3,
|
||||
"sum": 100
|
||||
},
|
||||
"output": {
|
||||
"a": 5,
|
||||
"b": 3,
|
||||
"sum": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 10,
|
||||
"b": 20,
|
||||
"extra": "This should pass through"
|
||||
},
|
||||
"output": {
|
||||
"a": 10,
|
||||
"b": 20,
|
||||
"sum": 30,
|
||||
"extra": "This should pass through"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 7,
|
||||
"b": 3,
|
||||
"sum": "Original",
|
||||
"passThrough": "Test"
|
||||
},
|
||||
"output": {
|
||||
"a": 7,
|
||||
"b": 3,
|
||||
"sum": 10,
|
||||
"passThrough": "Test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"a": 1,
|
||||
"b": 1,
|
||||
"c": 3,
|
||||
"d": 4
|
||||
},
|
||||
"output": {
|
||||
"a": 1,
|
||||
"b": 1,
|
||||
"c": 3,
|
||||
"d": 4,
|
||||
"sum": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"type": "inputNode",
|
||||
"id": "deced339-bace-452a-8db0-777f038bffe8",
|
||||
"name": "request",
|
||||
"position": {
|
||||
"x": 145,
|
||||
"y": 235
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "expressionNode",
|
||||
"content": {
|
||||
"expressions": [
|
||||
{
|
||||
"id": "d54641c2-5f24-4140-a9c4-8453542a622a",
|
||||
"key": "sum",
|
||||
"value": "a + b"
|
||||
}
|
||||
],
|
||||
"passThrough": true
|
||||
},
|
||||
"id": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770",
|
||||
"name": "expression1",
|
||||
"position": {
|
||||
"x": 475,
|
||||
"y": 235
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"id": "639f3a3a-7545-4e98-aa79-7a9bd9644af1",
|
||||
"sourceId": "deced339-bace-452a-8db0-777f038bffe8",
|
||||
"type": "edge",
|
||||
"targetId": "6b9cfc7e-4776-4b3f-8a19-c2a4d7874770"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user