commit 7d14da3a8c2a9b0f8d43459a1c155cec1c37c92c parent ffcf608de19719b0daff954df5a41aac96b8e55a Author: Dan Stillman <dan@danstillman.com> Date: Tue, 22 Aug 2017 02:45:33 +0200 Fix translator test mismatches due to 5.0 tag format Diffstat:
| M | chrome/content/zotero/tools/testTranslators/translatorTester.js | | | 16 | ++++++++++++---- |
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -298,10 +298,18 @@ Zotero_TranslatorTester._sanitizeItem = function(item, testItem, keepValidFields // remove fields to be ignored if(!keepValidFields && "accessDate" in item) delete item.accessDate; - - //sort tags, if they're still there - if(item.tags && typeof item.tags === "object" && "sort" in item.tags) { - item.tags = Zotero.Utilities.arrayUnique(item.tags).sort(); + + // Sort tags + if (item.tags && Array.isArray(item.tags)) { + // Normalize tags -- necessary until tests are updated for 5.0 + if (testItem) { + item.tags = Zotero.Translate.Base.prototype._cleanTags(item.tags); + } + item.tags.sort((a, b) => { + if (a.tag < b.tag) return -1; + if (b.tag < a.tag) return 1; + return 0; + }); } return item;