Skip to content

Commit

Permalink
Add json-patch-test-suite dep instead of copying tests into jiff
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Aug 20, 2015
1 parent a798b45 commit 2b42270
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 590 deletions.
10 changes: 9 additions & 1 deletion lib/patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ function applyAdd(x, change, options) {
throw new InvalidPatchOperationError('path does not exist ' + change.path);
}

if(change.value === void 0) {
throw new InvalidPatchOperationError('missing value');
}

var val = clone(change.value);

// If pointer refers to whole document, replace whole document
Expand All @@ -128,7 +132,7 @@ function _add(pointer, value) {
// '-' indicates 'append' to array
if(pointer.key === '-') {
target.push(value);
} else if (pointer.key > array.length) {
} else if (pointer.key > target.length) {
throw new InvalidPatchOperationError('target of add outside of array bounds')
} else {
target.splice(pointer.key, 0, value);
Expand Down Expand Up @@ -173,6 +177,10 @@ function applyReplace(x, change, options) {
throw new InvalidPatchOperationError('path does not exist ' + change.path);
}

if(change.value === void 0) {
throw new InvalidPatchOperationError('missing value');
}

var value = clone(change.value);

// If pointer refers to whole document, replace whole document
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"author": "[email protected]",
"license": "MIT",
"devDependencies": {
"jshint": "~2",
"buster": "~0.7",
"gent": "0.6.2"
"gent": "0.6.2",
"jshint": "~2",
"json-patch-test-suite": "^1.0.1"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions test/json-patch-tests-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ var deepEquals = require('../lib/deepEquals');

var jsonPatch = require('../lib/jsonPatch');

var specTests = require('./json-patch-tests/spec_tests.json');
var tests = require('./json-patch-tests/tests.json');
var specTests = require('json-patch-test-suite/spec_tests.json');
var tests = require('json-patch-test-suite/tests.json');

buster.testCase('json-patch-tests', {
'spec_tests.json': jsonToBuster(specTests),
Expand Down
50 changes: 0 additions & 50 deletions test/json-patch-tests/README.md

This file was deleted.

232 changes: 0 additions & 232 deletions test/json-patch-tests/spec_tests.json

This file was deleted.

Loading

0 comments on commit 2b42270

Please sign in to comment.