소스 검색

test: cover the default throw path for JSON parse failures

fszontagh 1 개월 전
부모
커밋
db4fcf0c6c
2개의 변경된 파일과 34개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      tests/nodes/json-errors-invalid.json
  2. 17 0
      tests/nodes/json-errors.json

+ 17 - 0
tests/nodes/json-errors-invalid.json

@@ -0,0 +1,17 @@
+{
+  "name": "verify-json-errors-invalid-json",
+  "nodes": [
+    {"id": "n1", "name": "Trigger", "type": "click-trigger", "position": {"x": 0, "y": 0}, "config": {}},
+    {"id": "n2", "name": "Fixture", "type": "code", "position": {"x": 0, "y": 100},
+     "config": {"code": "return { name: 'Ada', payload: 'not valid json' };"}},
+    {"id": "n3", "name": "ParseInvalidJson", "type": "json", "position": {"x": 0, "y": 200},
+     "config": {"operation": "parse", "inputField": "data.result.payload", "outputField": "value"}}
+  ],
+  "connections": [
+    {"sourceNodeId": "n1", "sourceOutput": "main", "targetNodeId": "n2", "targetInput": "data"},
+    {"sourceNodeId": "n2", "sourceOutput": "main", "targetNodeId": "n3", "targetInput": "data"}
+  ],
+  "expect": {
+    "n3": {"status": "failed"}
+  }
+}

+ 17 - 0
tests/nodes/json-errors.json

@@ -0,0 +1,17 @@
+{
+  "name": "verify-json-errors-not-a-string",
+  "nodes": [
+    {"id": "n1", "name": "Trigger", "type": "click-trigger", "position": {"x": 0, "y": 0}, "config": {}},
+    {"id": "n2", "name": "Fixture", "type": "code", "position": {"x": 0, "y": 100},
+     "config": {"code": "return { name: 'Ada', count: 7 };"}},
+    {"id": "n3", "name": "ParseNonString", "type": "json", "position": {"x": 0, "y": 200},
+     "config": {"operation": "parse", "inputField": "data.result.count", "outputField": "value"}}
+  ],
+  "connections": [
+    {"sourceNodeId": "n1", "sourceOutput": "main", "targetNodeId": "n2", "targetInput": "data"},
+    {"sourceNodeId": "n2", "sourceOutput": "main", "targetNodeId": "n3", "targetInput": "data"}
+  ],
+  "expect": {
+    "n3": {"status": "failed"}
+  }
+}