Fix translator test mismatches due to 5.0 tag format

This commit is contained in:
Dan Stillman 2017-08-22 02:45:33 +02:00 committed by Dan Stillman
parent ffcf608de1
commit 7d14da3a8c

View file

@ -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;