From ac34f2c4f4db59f2e29284c00f69434320786d3d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 19 Jul 2016 18:54:37 -0400 Subject: [PATCH] Allow additional options for support test functions - libraryVersion for createGroup() - Zotero.Item save options for importFileAttachment() --- test/content/support.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/content/support.js b/test/content/support.js index 6b660f4991..dc988713ed 100644 --- a/test/content/support.js +++ b/test/content/support.js @@ -307,6 +307,9 @@ var createGroup = Zotero.Promise.coroutine(function* (props = {}) { group.editable = props.editable === undefined ? true : props.editable; group.filesEditable = props.filesEditable === undefined ? true : props.filesEditable; group.version = props.version === undefined ? Zotero.Utilities.rand(1000, 10000) : props.version; + if (props.libraryVersion) { + group.libraryVersion = props.libraryVersion; + } yield group.saveTx(); return group; }); @@ -754,10 +757,14 @@ var generateTranslatorExportData = Zotero.Promise.coroutine(function* generateTr * @param {string} filename - The filename to import (in data directory) * @return {Promise} */ -function importFileAttachment(filename) { - let testfile = getTestDataDirectory(); - filename.split('/').forEach((part) => testfile.append(part)); - return Zotero.Attachments.importFromFile({file: testfile}); +function importFileAttachment(filename, options = {}) { + let file = getTestDataDirectory(); + filename.split('/').forEach((part) => file.append(part)); + let importOptions = { + file + }; + Object.assign(importOptions, options); + return Zotero.Attachments.importFromFile(importOptions); }