From f727b224e73e5b5ec6cd05b8aacfb8c6355b36d7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 14 May 2015 19:11:09 -0400 Subject: [PATCH] Fix tag diffing --- .../content/zotero/xpcom/data/dataObjects.js | 4 +- test/tests/dataObjectsTest.js | 40 +++++++++++++++++++ 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 index 4a0f75f44..ef57d4a12 100644 --- 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 index 73dd3ff77..8b4ece9e8 100644 --- 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); + }) }) })