Skip to content

Commit e95336f

Browse files
committedApr 26, 2020
add additional assumption test to ensure chokidar do not emit events after close
1 parent e27a81f commit e95336f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎test/Assumption.js

+33
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,37 @@ describe("Assumption", function() {
188188
});
189189
});
190190
});
191+
192+
[1, 10, 20, 50, 100, 200, 300, 400, 500].reverse().forEach(function(delay) {
193+
it("should not fire events after watcher has been closed after " + delay + "ms delay", function(done) {
194+
var watcher = watcherToClose = chokidar.watch(fixtures, {
195+
ignoreInitial: true,
196+
persistent: true,
197+
followSymlinks: false,
198+
depth: 0,
199+
atomic: false,
200+
alwaysStat: true,
201+
ignorePermissionErrors: true
202+
});
203+
watcher.on("add", function(arg) {
204+
done(new Error("should not be emitted " + arg));
205+
done = function() {};
206+
});
207+
watcher.on("change", function(arg) {
208+
done(new Error("should not be emitted " + arg));
209+
done = function() {};
210+
});
211+
watcher.on("error", function(err) {
212+
done(err);
213+
done = function() {};
214+
});
215+
testHelper.tick(delay, function() {
216+
watcher.close();
217+
testHelper.file("watch-test-file-close");
218+
testHelper.tick(500, function() {
219+
done();
220+
});
221+
});
222+
});
223+
});
191224
});

0 commit comments

Comments
 (0)
Please sign in to comment.