Skip to content

Commit

Permalink
Add failing test case for issue #31
Browse files Browse the repository at this point in the history
  • Loading branch information
alshakero committed Jun 2, 2018
1 parent b2d122d commit 24dd436
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/spec/duplexSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,33 @@ describe('duplex', function() {
}, 20);
});
});

describe('compare', function() {
it('Replacing a root array with an object should be handled well', function() {

const obj = {};
var patches = jsonpatch.compare(['jack'], obj);
expect(patches).toEqual([
{
op: 'replace',
path: '/',
value: obj
}
]);

});
it('Replacing a deep array with an object should be handled well', function() {

const obj = {};
var patches = jsonpatch.compare({arr: ['jack']}, {arr: obj});
expect(patches).toEqual([
{
op: 'replace',
path: '/arr',
value: obj
}
]);

});
it('should return an add for a property that does not exist in the first obj', function() {
var objA = {
user: {
Expand Down

0 comments on commit 24dd436

Please sign in to comment.