From 02a48c5a8412c5bfa61ae48ae09c4d04de71492e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 10 Apr 2024 07:13:47 -0400 Subject: [PATCH] Add test for importing BibTeX from the clipboard --- test/tests/fileInterfaceTest.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/tests/fileInterfaceTest.js b/test/tests/fileInterfaceTest.js index bbe7650293..a8e56fb9d9 100644 --- a/test/tests/fileInterfaceTest.js +++ b/test/tests/fileInterfaceTest.js @@ -111,6 +111,26 @@ describe("Zotero_File_Interface", function() { assert.equal(item.getField('title'), "Test"); }); + + describe("#importFromClipboard()", function () { + it("should import BibTeX from the clipboard", async function () { + var str = "@article{last_test_nodate,\n title = {Test},\n author = {Last, First},\n}"; + Zotero.Utilities.Internal.copyTextToClipboard(str); + var promise = waitForItemEvent('add'); + await win.Zotero_File_Interface.importFromClipboard(); + var ids = await promise; + assert.lengthOf(ids, 1); + + var item = Zotero.Items.get(ids[0]); + assert.equal(item.itemTypeID, Zotero.ItemTypes.getID('journalArticle')); + assert.equal(item.getField('title'), "Test"); + var creator = item.getCreators()[0]; + assert.propertyVal(creator, 'firstName', "First") + assert.propertyVal(creator, 'lastName', "Last") + }); + }); + + describe("#copyItemsToClipboard()", function () { var clipboardService, item1, item2;