Skip to content

Commit e96e5a8

Browse files
committed
add more index error tests for #5
1 parent 7e591b6 commit e96e5a8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,40 @@
263263
"patch": [ { "op": "add", "path": "/2/1/-", "value": { "foo": [ "bar", "baz" ] } } ],
264264
"expected": [ 1, 2, [ 3, [ 4, 5, { "foo": [ "bar", "baz" ] } ] ] ]},
265265

266+
{ "comment": "test remove with bad number should fail",
267+
"doc": {"foo": 1, "baz": [{"qux": "hello"}]},
268+
"patch": [{"op": "remove", "path": "/baz/1e0/qux"}],
269+
"error": "remove op shouldn't remove from array with bad number" },
270+
271+
{ "comment": "test remove on array",
272+
"doc": [1, 2, 3, 4],
273+
"patch": [{"op": "remove", "path": "/0"}],
274+
"expected": [2, 3, 4] },
275+
276+
{ "comment": "test remove with bad index should fail",
277+
"doc": [1, 2, 3, 4],
278+
"patch": [{"op": "remove", "path": "/1e0"}],
279+
"error": "remove op shouldn't remove from array with bad number" },
280+
281+
{ "comment": "test replace with bad number should fail",
282+
"doc": [""],
283+
"patch": [{"op": "replace", "path": "/1e0", "value": false}],
284+
"error": "replace op shouldn't replace in array with bad number" },
285+
286+
{ "comment": "test copy with bad number should fail",
287+
"doc": {"baz": [1,2,3], "bar": 1},
288+
"patch": [{"op": "copy", "from": "/baz/1e0", "path": "/boo"}],
289+
"error": "copy op shouldn't work with bad number" },
290+
291+
{ "comment": "test move with bad number should fail",
292+
"doc": {"foo": 1, "baz": [1,2,3,4]},
293+
"patch": [{"op": "move", "from": "/baz/1e0", "path": "/foo"}],
294+
"error": "move op shouldn't work with bad number" },
295+
296+
{ "comment": "test add with bad number should fail",
297+
"doc": ["foo", "sil"],
298+
"patch": [{"op": "add", "path": "/1e0", "value": "bar"}],
299+
"error": "add op shouldn't add to array with bad number" },
300+
266301
{ "comment": "tests complete" }
267302
]

0 commit comments

Comments
 (0)