Просмотр исходного кода

[test/unit] misc: cleanup a pending interval

Jakob Ackermann 6 лет назад
Родитель
Сommit
90d12cc602

+ 2 - 1
services/spelling/app/js/ASpell.js

@@ -32,7 +32,7 @@ try {
 }
 
 // write the cache every 30 minutes
-setInterval(function() {
+const cacheDump = setInterval(function() {
   const dump = JSON.stringify(cache.dump())
   return fs.writeFile(cacheFsPathTmp, dump, function(err) {
     if (err != null) {
@@ -186,3 +186,4 @@ ASpell.promises = promises
 module.exports = ASpell
 
 var WorkerPool = new ASpellWorkerPool()
+module.exports.cacheDump = cacheDump

+ 3 - 0
services/spelling/test/unit/js/ASpellTests.js

@@ -30,6 +30,9 @@ describe('ASpell', function() {
       }
     }))
   })
+  afterEach(function () {
+    clearInterval(this.ASpell.cacheDump)
+  })
 
   describe('a correctly spelled word', function() {
     beforeEach(function(done) {