Commit 8daf132
committed
feat: Add comprehensive tests for generateJSONPatch
This commit significantly enhances the test coverage for the `generateJSONPatch`
function in `src/index.spec.ts`.
The new tests cover a wide range of scenarios, including:
- **Combined Configurations:** Interactions between `objectHash`, `propertyFilter`,
and `maxDepth` options.
- **`objectHash` Edge Cases:** Behavior with non-string return values from the
hashing function and error handling when the function itself throws.
- **`propertyFilter` Edge Cases:** Error handling for the filter function and
more complex filtering logic based on paths and context.
- **`maxDepth` Edge Cases:** Specific tests for `maxDepth: 0` and detailed
interactions with arrays of complex objects, especially when `objectHash`
is also used.
- **Complex `move` Operations:** Scenarios involving multiple moves, moves
combined with add/remove operations, moves to array boundaries, moves in
nested arrays, and behavior with `objectHash` collisions.
- **General Error Handling:** Validation of option types for `maxDepth`,
`propertyFilter`, and `array.ignoreMove`, ensuring appropriate errors
are thrown for invalid inputs.
These additions improve the robustness and reliability of the JSON patch
generation by ensuring various configurations and edge conditions are
thoroughly tested.1 parent 507fe16 commit 8daf132
1 file changed
+1332
-0
lines changed
0 commit comments