Skip to content

Commit

Permalink
add additional assumption test to ensure chokidar do not emit events …
Browse files Browse the repository at this point in the history
…after close
  • Loading branch information
sokra committed Apr 26, 2020
1 parent e27a81f commit e95336f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/Assumption.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,37 @@ describe("Assumption", function() {
});
});
});

[1, 10, 20, 50, 100, 200, 300, 400, 500].reverse().forEach(function(delay) {
it("should not fire events after watcher has been closed after " + delay + "ms delay", function(done) {
var watcher = watcherToClose = chokidar.watch(fixtures, {
ignoreInitial: true,
persistent: true,
followSymlinks: false,
depth: 0,
atomic: false,
alwaysStat: true,
ignorePermissionErrors: true
});
watcher.on("add", function(arg) {
done(new Error("should not be emitted " + arg));
done = function() {};
});
watcher.on("change", function(arg) {
done(new Error("should not be emitted " + arg));
done = function() {};
});
watcher.on("error", function(err) {
done(err);
done = function() {};
});
testHelper.tick(delay, function() {
watcher.close();
testHelper.file("watch-test-file-close");
testHelper.tick(500, function() {
done();
});
});
});
});
});

0 comments on commit e95336f

Please sign in to comment.