Skip to content

Commit 60ac254

Browse files
committed
Add tests for applyPatch validation
1 parent d84e3f0 commit 60ac254

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/spec/validateSpec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ describe('validate', function() {
3838
expect(error).toBeUndefined();
3939
});
4040

41-
it('should return an error if the patch is not an array', function() {
42-
var error = jsonpatch.validate({});
43-
expect(error instanceof jsonpatch.JsonPatchError).toBe(true);
44-
expect(error.name).toBe('SEQUENCE_NOT_AN_ARRAY');
45-
expect(error.message).toBe('Patch sequence must be an array');
41+
it('applyPatch should throw an error if the patch is not an array and validate is `true`', function() {
42+
expect(() =>jsonpatch.applyPatch({}, {}, true)).toThrow(new jsonpatch.JsonPatchError('Patch sequence must be an array'));
43+
});
44+
it('applyPatch should throw an error if the patch is not an array and validate is `true`', function() {
45+
expect(() =>jsonpatch.applyPatch({}, null, true)).toThrow(new jsonpatch.JsonPatchError('Patch sequence must be an array'));
4646
});
4747

4848
it('should return an empty array if the operation is a valid object', function() {

0 commit comments

Comments
 (0)