Set test timeout in resetDB() instead of separate this.timeout() calls

'thisArg: this' should be passed to resetDB to have it adjust the
timeout
This commit is contained in:
Dan Stillman 2015-09-29 04:07:26 -04:00
parent 88627adcdb
commit 7633c7de30
4 changed files with 14 additions and 8 deletions

View File

@ -426,6 +426,9 @@ var getTempDirectory = Zotero.Promise.coroutine(function* getTempDirectory() {
* any that were set at startup * any that were set at startup
*/ */
function resetDB(options = {}) { function resetDB(options = {}) {
if (options.thisArg) {
options.thisArg.timeout(60000);
}
var db = Zotero.getZoteroDatabase(); var db = Zotero.getZoteroDatabase();
return Zotero.reinit(function() { return Zotero.reinit(function() {
db.remove(false); db.remove(false);

View File

@ -1,8 +1,9 @@
describe("Support Functions for Unit Testing", function() { describe("Support Functions for Unit Testing", function() {
describe("resetDB", function() { describe("resetDB", function() {
it("should restore the DB to factory settings", function* () { it("should restore the DB to factory settings", function* () {
this.timeout(60000); yield resetDB({
yield resetDB(); thisArg: this
});
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM items")), 0); assert.equal((yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM items")), 0);
}); });
}); });

View File

@ -108,8 +108,8 @@ describe("Zotero.Sync.Data.Engine", function () {
// Tests // Tests
// //
beforeEach(function* () { beforeEach(function* () {
this.timeout(60000);
yield resetDB({ yield resetDB({
thisArg: this,
skipBundledFiles: true skipBundledFiles: true
}); });
@ -119,8 +119,9 @@ describe("Zotero.Sync.Data.Engine", function () {
yield Zotero.Users.setCurrentUsername("testuser"); yield Zotero.Users.setCurrentUsername("testuser");
}) })
after(function* () { after(function* () {
this.timeout(60000); yield resetDB({
yield resetDB(); thisArg: this
});
}) })
describe("Syncing", function () { describe("Syncing", function () {

View File

@ -445,16 +445,17 @@ describe("Zotero.Sync.Runner", function () {
describe("#sync()", function () { describe("#sync()", function () {
before(function* () { before(function* () {
this.timeout(60000);
yield resetDB({ yield resetDB({
thisArg: this,
skipBundledFiles: true skipBundledFiles: true
}); });
yield Zotero.Libraries.init(); yield Zotero.Libraries.init();
}) })
after(function* () { after(function* () {
this.timeout(60000); yield resetDB({
yield resetDB(); thisArg: this
});
}) })
it("should perform a sync across all libraries", function* () { it("should perform a sync across all libraries", function* () {