Comparing version 1.0.4 to 1.0.5
14
index.js
@@ -118,5 +118,13 @@ /** | ||
} else { | ||
_.forOwn(array, function (value, key) { | ||
// TODO handle arrays of arrays or objects | ||
}); | ||
// Handle arrays | ||
path.push(key); | ||
for (var index in array) { | ||
path.push(index); | ||
var differences = recurse(parentValue[index], theirsValue[index], mineValue[index], path, options[key] || {}); | ||
if (differences) { | ||
results = results.concat(differences); | ||
} | ||
path.pop(); | ||
} | ||
path.pop(); | ||
} | ||
@@ -123,0 +131,0 @@ } |
{ | ||
"name": "3-way-diff", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "3-way diffing of JavaScript objects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -197,4 +197,60 @@ var assert = require('assert'); | ||
}); | ||
it('both children edit same array item to same array values', function() { | ||
var parent = { | ||
key: [ | ||
{childKey1: 'value1'}, | ||
{childKey2: 'value2'} | ||
] | ||
}; | ||
var theirs = { | ||
key: [ | ||
{childKey1: 'value3'}, | ||
{childKey2: 'value2'} | ||
] | ||
}; | ||
var mine = { | ||
key: [ | ||
{childKey1: 'value3'}, | ||
{childKey2: 'value2'} | ||
] | ||
}; | ||
var expected = [ | ||
// No differences | ||
]; | ||
assert.deepEqual(diff(parent, theirs, mine), expected); | ||
}); | ||
it('both children edit same array item to different array values', function() { | ||
var parent = { | ||
key: [ | ||
{childKey1: 'value1'}, | ||
{childKey2: 'value2'} | ||
] | ||
}; | ||
var theirs = { | ||
key: [ | ||
{childKey1: 'value3'}, | ||
{childKey2: 'value2'} | ||
] | ||
}; | ||
var mine = { | ||
key: [ | ||
{childKey1: 'value4'}, | ||
{childKey2: 'value2'} | ||
] | ||
}; | ||
var expected = [ | ||
{ | ||
kind: 'C', | ||
path: [ 'key', '0', 'childKey1' ], | ||
parent: parent.key[0].childKey1, | ||
theirs: theirs.key[0].childKey1, | ||
mine: mine.key[0].childKey1 | ||
} | ||
]; | ||
assert.deepEqual(diff(parent, theirs, mine), expected); | ||
}); | ||
}); | ||
// TODO These are probably useful tests https://github.com/falsecz/3-way-merge/blob/master/test/test.coffee |
28335
950