Skip to content

Commit 6f8d4e6

Browse files
committed
Add tests to add to the end of an array using /-
1 parent 4db5098 commit 6f8d4e6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,15 @@
253253
"patch": [{"op": "add", "path": "", "value": {"baz": "qux"}}],
254254
"expected": {"baz":"qux"}},
255255

256+
{ "comment": "Adding to \"/-\" adds to the end of the array",
257+
"doc": [ 1, 2 ],
258+
"patch": [ { "op": "add", "path": "/-", "value": { "foo": [ "bar", "baz" ] } } ],
259+
"expected": [ 1, 2, { "foo": [ "bar", "baz" ] } ]},
260+
261+
{ "comment": "Adding to \"/-\" adds to the end of the array, even n levels down",
262+
"doc": [ 1, 2, [ 3, [ 4, 5 ] ] ],
263+
"patch": [ { "op": "add", "path": "/2/1/-", "value": { "foo": [ "bar", "baz" ] } } ],
264+
"expected": [ 1, 2, [ 3, [ 4, 5, { "foo": [ "bar", "baz" ] } ] ] ]},
265+
256266
{ "comment": "tests complete" }
257267
]

0 commit comments

Comments
 (0)