|
171 | 171 | "expected": ["foo", ["bar", "baz"]],
|
172 | 172 | "comment": "value in array replace not flattened" },
|
173 | 173 |
|
| 174 | + { "comment": "replace whole document", |
| 175 | + "doc": {"foo": "bar"}, |
| 176 | + "patch": [{"op": "replace", "path": "", "value": {"baz": "qux"}}], |
| 177 | + "expected": {"baz": "qux"} }, |
| 178 | + |
174 | 179 | { "comment": "spurious patch properties",
|
175 | 180 | "doc": {"foo": 1},
|
176 | 181 | "patch": [{"op": "test", "path": "/foo", "value": 1, "spurious": 1}],
|
|
196 | 201 | "patch": [{"op": "test", "path": "/foo", "value": [1, 2]}],
|
197 | 202 | "error": "test op should fail" },
|
198 | 203 |
|
199 |
| - { "comment": "json-pointer tests" }, |
200 |
| - |
201 | 204 | { "comment": "Whole document",
|
202 | 205 | "doc": { "foo": 1 },
|
203 | 206 | "patch": [{"op": "test", "path": "", "value": {"foo": 1}}],
|
|
263 | 266 | "patch": [ { "op": "add", "path": "/2/1/-", "value": { "foo": [ "bar", "baz" ] } } ],
|
264 | 267 | "expected": [ 1, 2, [ 3, [ 4, 5, { "foo": [ "bar", "baz" ] } ] ] ]},
|
265 | 268 |
|
266 |
| - { "comment": "tests complete" } |
| 269 | + { "comment": "test remove with bad number should fail", |
| 270 | + "doc": {"foo": 1, "baz": [{"qux": "hello"}]}, |
| 271 | + "patch": [{"op": "remove", "path": "/baz/1e0/qux"}], |
| 272 | + "error": "remove op shouldn't remove from array with bad number" }, |
| 273 | + |
| 274 | + { "comment": "test remove on array", |
| 275 | + "doc": [1, 2, 3, 4], |
| 276 | + "patch": [{"op": "remove", "path": "/0"}], |
| 277 | + "expected": [2, 3, 4] }, |
| 278 | + |
| 279 | + { "comment": "test remove with bad index should fail", |
| 280 | + "doc": [1, 2, 3, 4], |
| 281 | + "patch": [{"op": "remove", "path": "/1e0"}], |
| 282 | + "error": "remove op shouldn't remove from array with bad number" }, |
| 283 | + |
| 284 | + { "comment": "test replace with bad number should fail", |
| 285 | + "doc": [""], |
| 286 | + "patch": [{"op": "replace", "path": "/1e0", "value": false}], |
| 287 | + "error": "replace op shouldn't replace in array with bad number" }, |
| 288 | + |
| 289 | + { "comment": "test copy with bad number should fail", |
| 290 | + "doc": {"baz": [1,2,3], "bar": 1}, |
| 291 | + "patch": [{"op": "copy", "from": "/baz/1e0", "path": "/boo"}], |
| 292 | + "error": "copy op shouldn't work with bad number" }, |
| 293 | + |
| 294 | + { "comment": "test move with bad number should fail", |
| 295 | + "doc": {"foo": 1, "baz": [1,2,3,4]}, |
| 296 | + "patch": [{"op": "move", "from": "/baz/1e0", "path": "/foo"}], |
| 297 | + "error": "move op shouldn't work with bad number" }, |
| 298 | + |
| 299 | + { "comment": "test add with bad number should fail", |
| 300 | + "doc": ["foo", "sil"], |
| 301 | + "patch": [{"op": "add", "path": "/1e0", "value": "bar"}], |
| 302 | + "error": "add op shouldn't add to array with bad number" } |
267 | 303 | ]
|
0 commit comments