Fix tag diffing

This commit is contained in:
Dan Stillman 2015-05-14 19:11:09 -04:00
parent 3f4eebe51c
commit f727b224e7
2 changed files with 43 additions and 1 deletions

View File

@ -543,7 +543,9 @@ Zotero.DataObjects.prototype._diffCollections = function (data1, data2) {
Zotero.DataObjects.prototype._diffTags = function (data1, data2) {
if (data1.length != data2.length) return false;
for (let i = 0; i < data1.length; i++) {
if (c1.tag !== c2.tag || (c1.type || 0) !== (c2.type || 0)) {
let t1 = data1[i];
let t2 = data2[i];
if (t1.tag !== t2.tag || (t1.type || 0) !== (t2.type || 0)) {
return false;
}
}

View File

@ -66,5 +66,45 @@ describe("Zotero.DataObjects", function() {
var diff = Zotero.Items.diff(json1, json2);
assert.isFalse(diff);
})
it("should show tags of different types as different", function* () {
var json1 = {
tags: [
{
tag: "Foo"
}
]
};
var json2 = {
tags: [
{
tag: "Foo",
type: 1
}
]
};
var diff = Zotero.Items.diff(json1, json2);
assert.isFalse(diff);
})
it("should not show manual tags as different without 'type' property", function* () {
var json1 = {
tags: [
{
tag: "Foo"
}
]
};
var json2 = {
tags: [
{
tag: "Foo",
type: 0
}
]
};
var diff = Zotero.Items.diff(json1, json2);
assert.isFalse(diff);
})
})
})