Reset Zotero prefs after each suite and when resetting DB
But keep prefs set in runtests.sh
This commit is contained in:
parent
30d0858ebf
commit
5bceebf56c
2 changed files with 33 additions and 1 deletions
|
@ -196,6 +196,38 @@ mocha.setup({
|
|||
};
|
||||
})();
|
||||
|
||||
before(function () {
|
||||
// Store all prefs set in runtests.sh
|
||||
var prefBranch = Services.prefs.getBranch(ZOTERO_CONFIG.PREF_BRANCH);
|
||||
ZoteroUnit.customPrefs = {};
|
||||
prefBranch.getChildList("", {})
|
||||
.filter(key => prefBranch.prefHasUserValue(key))
|
||||
.forEach(key => ZoteroUnit.customPrefs[key] = Zotero.Prefs.get(key));
|
||||
});
|
||||
|
||||
/**
|
||||
* Clear all prefs, and reset those set in runtests.sh to original values
|
||||
*/
|
||||
function resetPrefs() {
|
||||
var prefBranch = Services.prefs.getBranch(ZOTERO_CONFIG.PREF_BRANCH);
|
||||
prefBranch.getChildList("", {}).forEach(key => {
|
||||
var origVal = ZoteroUnit.customPrefs[key];
|
||||
if (origVal !== undefined) {
|
||||
if (origVal != Zotero.Prefs.get(key)) {
|
||||
Zotero.Prefs.set(key, ZoteroUnit.customPrefs[key]);
|
||||
}
|
||||
}
|
||||
else if (prefBranch.prefHasUserValue(key)) {
|
||||
Zotero.Prefs.clear(key)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(function () {
|
||||
resetPrefs();
|
||||
});
|
||||
|
||||
|
||||
var assert = chai.assert,
|
||||
expect = chai.expect;
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ var removeDir = Zotero.Promise.coroutine(function* (dir) {
|
|||
* any that were set at startup
|
||||
*/
|
||||
function resetDB(options = {}) {
|
||||
Zotero.Prefs.clear('lastViewedFolder')
|
||||
resetPrefs();
|
||||
|
||||
if (options.thisArg) {
|
||||
options.thisArg.timeout(60000);
|
||||
|
|
Loading…
Reference in a new issue