Skip to content

Commit

Permalink
Allow overriding startup options in Zotero.reinit()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dstillman committed Jul 20, 2015
1 parent 9d0d79c commit 02cd71e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions components/zotero-service.js
Expand Up @@ -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);
});
}
};
Expand Down
7 changes: 5 additions & 2 deletions test/content/support.js
Expand Up @@ -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;
});
}
Expand Down

0 comments on commit 02cd71e

Please sign in to comment.