From 02cd71ebb5f779f0dc946c416fd0c04aecd8d515 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 19 Jul 2015 17:58:58 -0400 Subject: [PATCH] Allow overriding startup options in Zotero.reinit() And use it in resetDB() test support function, mainly to allow skipBundledFiles for resetDB calls. Translator installation and initialization can take a long time, but tests that need a clean DB don't necessarily rely on translators. Without this, running resetDB() in beforeEach() for many tests is prohibitively slow. --- components/zotero-service.js | 7 +++++-- test/content/support.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/zotero-service.js b/components/zotero-service.js index 38a373de6..c45b00894 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -186,13 +186,16 @@ ZoteroContext.prototype = { * then reinitializes Zotero. Returns a promise that is resolved * when this process completes. */ - "reinit":function(cb, isConnector) { + "reinit":function(cb, isConnector, options = {}) { Services.obs.notifyObservers(zContext.Zotero, "zotero-before-reload", isConnector ? "connector" : "full"); return zContext.Zotero.shutdown().then(function() { return cb ? cb() : false; }).finally(function() { makeZoteroContext(isConnector); - zContext.Zotero.init(zInitOptions); + var o = {}; + Object.assign(o, zInitOptions); + Object.assign(o, options); + zContext.Zotero.init(o); }); } }; diff --git a/test/content/support.js b/test/content/support.js index ade80e416..61a1b917f 100644 --- a/test/content/support.js +++ b/test/content/support.js @@ -366,13 +366,16 @@ var getTempDirectory = Zotero.Promise.coroutine(function* getTempDirectory() { /** * Resets the Zotero DB and restarts Zotero. Returns a promise resolved * when this finishes. + * + * @param {Object} [options] - Initialization options, as passed to Zotero.init(), overriding + * any that were set at startup */ -function resetDB() { +function resetDB(options = {}) { var db = Zotero.getZoteroDatabase(); return Zotero.reinit(function() { db.remove(false); _defaultGroup = null; - }).then(function() { + }, false, options).then(function() { return Zotero.Schema.schemaUpdatePromise; }); }