diff options
-rw-r--r-- | test/test-database.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/test-database.js b/test/test-database.js index 44f409dd..add04a03 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -109,7 +109,8 @@ function countKanjiWithCharacter(kanji, character) { function clearDatabase(timeout) { return new Promise((resolve, reject) => { - const timer = setTimeout(() => { + let timer = setTimeout(() => { + timer = null; reject(new Error(`clearDatabase failed to resolve after ${timeout}ms`)); }, timeout); @@ -122,7 +123,9 @@ function clearDatabase(timeout) { request.onsuccess = () => resolve2(); }); } - clearTimeout(timer); + if (timer !== null) { + clearTimeout(timer); + } resolve(); })(); }); |