commit f727b224e73e5b5ec6cd05b8aacfb8c6355b36d7
parent 3f4eebe51cbdf01691362ca83c1764e775dccfd9
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 14 May 2015 19:11:09 -0400
Fix tag diffing
Diffstat:
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js
@@ -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;
}
}
diff --git a/test/tests/dataObjectsTest.js b/test/tests/dataObjectsTest.js
@@ -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);
+ })
})
})