Skip to content

Commit d829738

Browse files
committed
Additional test cases to cover explicit type check
1 parent 452aa1a commit d829738

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

tests/divide.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,18 @@
189189
"rule": { "/": [8, 2, 0] },
190190
"error": { "type": "NaN" },
191191
"data": null
192+
},
193+
{
194+
"description": "Divide Operator with val resulting in Array of array should error",
195+
"rule": { "/": [{ "val": "arr" }] },
196+
"error": { "type": "NaN" },
197+
"data": {"arr": [100, 4, 5]}
198+
},
199+
{
200+
"description": "Divide Operator with val resulting in Array should divide sequentially",
201+
"rule": { "/": { "val": "arr" } },
202+
"result": 5,
203+
"data": {"arr": [100, 4, 5]},
204+
"decimal": false
192205
}
193206
]

tests/exists.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,17 @@
4747
"rule": { "exists": "hello" },
4848
"data": { "hello" : null },
4949
"result": true
50+
},
51+
{
52+
"description": "Check deeply nested path",
53+
"rule": { "exists": ["a", "b", "c", "d"] },
54+
"data": { "a": { "b": { "c": { "d": 1 } } } },
55+
"result": true
56+
},
57+
{
58+
"description": "Check deeply nested path (false)",
59+
"rule": { "exists": ["a", "b", "c", "d"] },
60+
"data": { "a": { "b": { "c": { "x": 1 } } } },
61+
"result": false
5062
}
5163
]

tests/minus.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,17 @@
132132
"rule": { "-": [[1], 1] },
133133
"error": { "type": "NaN" },
134134
"data": null
135+
},
136+
{
137+
"description": "Minus Operator with val resulting in Array of array should error",
138+
"rule": { "-": [{ "val": "arr" }] },
139+
"error": { "type": "NaN" },
140+
"data": {"arr": [1, 2, 3, 4]}
141+
},
142+
{
143+
"description": "Minus Operator with val resulting in Array should subtract sequentially",
144+
"rule": { "-": { "val": "arr" } },
145+
"result": -8,
146+
"data": {"arr": [1, 2, 3, 4]}
135147
}
136148
]

tests/modulo.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,17 @@
187187
"rule": { "%": [8, -3] },
188188
"result": 2,
189189
"data": null
190+
},
191+
{
192+
"description": "Modulo Operator with val resulting in Array of array should error",
193+
"rule": { "%": [{ "val": "arr" }] },
194+
"error": { "type": "NaN" },
195+
"data": {"arr": [10, 6, 4]}
196+
},
197+
{
198+
"description": "Modulo Operator with val resulting in Array should modulo sequentially",
199+
"rule": { "%": { "val": "arr" } },
200+
"result": 2,
201+
"data": {"arr": [10, 6, 4]}
190202
}
191203
]

tests/multiply.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,17 @@
168168
"rule": { "*": [[1], 1] },
169169
"error": { "type": "NaN" },
170170
"data": null
171+
},
172+
{
173+
"description": "Multiply Operator with val resulting in Array of array should error",
174+
"rule": { "*": [{ "val": "arr" }] },
175+
"error": { "type": "NaN" },
176+
"data": {"arr": [1, 2, 3, 4]}
177+
},
178+
{
179+
"description": "Multiply Operator with val resulting in Array should multiply",
180+
"rule": { "*": { "val": "arr" } },
181+
"result": 24,
182+
"data": {"arr": [1, 2, 3, 4]}
171183
}
172184
]

tests/plus.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,17 @@
194194
"rule": { "+": {} },
195195
"error": { "type": "NaN" },
196196
"data": null
197+
},
198+
{
199+
"description": "Plus Operator with val resulting in Array of array should error",
200+
"rule": { "+": [{ "val": "arr" }] },
201+
"error": { "type": "NaN" },
202+
"data": {"arr": [1, 2, 3, 4]}
203+
},
204+
{
205+
"description": "Plus Operator with val resulting in Array should sum",
206+
"rule": { "+": { "val": "arr" } },
207+
"result": 10,
208+
"data": {"arr": [1, 2, 3, 4]}
197209
}
198210
]

0 commit comments

Comments
 (0)