commit c0a4fa43f01d8e80b3054f9f5af8012f00908682
parent 8f39e9cb367dae156e74083a28e581594ca5ffe8
Author: Martynas Bagdonas <martbgd@gmail.com>
Date: Fri, 4 May 2018 10:14:26 +0300
Add a test for PDF recognition by DOI (#1496)
Diffstat:
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/test/tests/data/recognizePDF_test_DOI.pdf b/test/tests/data/recognizePDF_test_DOI.pdf
Binary files differ.
diff --git a/test/tests/recognizePDFTest.js b/test/tests/recognizePDFTest.js
@@ -28,7 +28,40 @@ describe("PDF Recognition", function() {
}
});
- it.skip("should recognize a PDF by DOI");
+ it("should recognize a PDF by DOI", async function () {
+ this.timeout(30000);
+ // Import the PDF
+ var testdir = getTestDataDirectory();
+ testdir.append("recognizePDF_test_DOI.pdf");
+ var collection = await createDataObject('collection');
+ var attachment = await Zotero.Attachments.importFromFile({
+ file: testdir,
+ collections: [collection.id]
+ });
+
+ win.ZoteroPane.recognizeSelected();
+
+ var addedIDs = await waitForItemEvent("add");
+ var modifiedIDs = await waitForItemEvent("modify");
+ assert.lengthOf(addedIDs, 1);
+ var item = Zotero.Items.get(addedIDs[0]);
+ assert.equal(item.getField("title"), "Shaping the Research Agenda");
+ assert.equal(item.getField("libraryCatalog"), "Crossref");
+ assert.lengthOf(modifiedIDs, 2);
+
+ // Wait for status to show as complete
+ var progressWindow = getWindows("chrome://zotero/content/recognizePDFDialog.xul")[0];
+ var completeStr = Zotero.getString("recognizePDF.complete.label");
+ while (progressWindow.document.getElementById("label").value != completeStr) {
+ await Zotero.Promise.delay(20);
+ }
+
+ // The file should have been renamed
+ assert.equal(
+ attachment.attachmentFilename,
+ Zotero.Attachments.getFileBaseNameFromItem(item) + '.pdf'
+ );
+ });
it("should recognize a PDF by arXiv ID", async function () {
this.timeout(30000);