Components.utils.import("resource://gre/modules/osfile.jsm"); describe("Zotero.Translate.ItemGetter", function() { describe("nextItem", function() { it('should return false for an empty database', function() { let getter = new Zotero.Translate.ItemGetter(); assert.isFalse(getter.nextItem()); }); it('should return items in order they are supplied', function() { let getter = new Zotero.Translate.ItemGetter(); Zotero.DB.beginTransaction(); let itemIDs = [ (new Zotero.Item('journalArticle')).save(), (new Zotero.Item('book')).save() ]; let items = [ Zotero.Items.get(itemIDs[0]), Zotero.Items.get(itemIDs[1]) ]; let itemURIs = items.map(i => Zotero.URI.getItemURI(i)); Zotero.DB.commitTransaction(); getter._itemsLeft = items; assert.equal(getter.nextItem().uri, itemURIs[0], 'first item comes out first'); assert.equal(getter.nextItem().uri, itemURIs[1], 'second item comes out second'); assert.isFalse(getter.nextItem(), 'end of item queue'); }); it('should return items with tags in expected format', function() { let getter = new Zotero.Translate.ItemGetter(); Zotero.DB.beginTransaction(); let itemWithAutomaticTag = Zotero.Items.get((new Zotero.Item('journalArticle')).save()); itemWithAutomaticTag.addTag('automatic tag', 0); let itemWithManualTag = Zotero.Items.get((new Zotero.Item('journalArticle')).save()); itemWithManualTag.addTag('manual tag', 1); let itemWithMultipleTags = Zotero.Items.get((new Zotero.Item('journalArticle')).save()); itemWithMultipleTags.addTag('tag1', 0); itemWithMultipleTags.addTag('tag2', 1); Zotero.DB.commitTransaction(); let legacyMode = [false, true]; for (let i=0; i