describe("Zotero_File_Interface", function() { let win; before(function* () { win = yield loadZoteroPane(); yield OS.File.copy(OS.Path.join(getTestDataDirectory().path, "Test Import Translator.js"), OS.Path.join(Zotero.getTranslatorsDirectory().path, "Test Import Translator.js")); yield Zotero.Translators.reinit(); }); after(function () { win.close(); }); it('should import a file into a collection', function* () { this.timeout(10000); let testFile = getTestDataDirectory(); testFile.append("allTypesAndFields.js"); yield win.Zotero_File_Interface.importFile(testFile); let importedCollection = Zotero.Collections.getByLibrary( Zotero.Libraries.userLibraryID ).filter(x => x.name == 'allTypesAndFields'); assert.equal(importedCollection.length, 1); let childItems = importedCollection[0].getChildItems(); let savedItems = {}; for (let i=0; iA, 2016; B, 2016)'); // Plain text str = getDataForFlavor('text/unicode'); assert.equal(str, '(A, 2016; B, 2016)'); }); it("should copy HTML and text bibliography to the clipboard", function* () { win.Zotero_File_Interface.copyItemsToClipboard( [item1, item2], 'http://www.zotero.org/styles/apa', 'en-US' ); var str = getDataForFlavor('text/html'); assert.include(str, 'line-height'); assert.include(str, 'A'); assert.include(str, 'B'); // Plain text str = getDataForFlavor('text/unicode'); assert.equal(str, 'A. (2016).\nB. (2016).\n'); }); // // "Copy as HTML" mode // it("should copy HTML and HTML source citations to the clipboard", function* () { win.Zotero_File_Interface.copyItemsToClipboard( [item1, item2], 'http://www.zotero.org/styles/apa', 'en-US', true, true ); var str = getDataForFlavor('text/html'); assert.equal(str, '(A, 2016; B, 2016)'); // Plain text str = getDataForFlavor('text/unicode'); assert.equal(str, '(A, 2016; B, 2016)'); }); it("should copy HTML and HTML source bibliography to the clipboard", function* () { win.Zotero_File_Interface.copyItemsToClipboard( [item1, item2], 'http://www.zotero.org/styles/apa', 'en-US', true ); var str = getDataForFlavor('text/html'); assert.include(str, 'line-height'); assert.include(str, 'A'); assert.include(str, 'B'); // Plain text str = getDataForFlavor('text/unicode'); assert.include(str, 'line-height'); assert.include(str, 'A'); assert.include(str, 'B'); }); }); });