From 3c5eefdac2612a32aa7c94a029886fbdec0a0f87 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 12 Mar 2024 16:42:41 +0300 Subject: [PATCH] test: more --- test/DirectoryWatcher.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/DirectoryWatcher.js b/test/DirectoryWatcher.js index f5cf8d8..30c1757 100644 --- a/test/DirectoryWatcher.js +++ b/test/DirectoryWatcher.js @@ -169,7 +169,30 @@ describe("DirectoryWatcher", function() { }); }); - it("should not report directory as initial missing on the second watch", function(done) { + it("should report directory as initial missing on the second watch when directory doesn't exist", function(done) { + var wm = getWatcherManager({}); + testHelper.dir("dir1"); + wm.watchDirectory(path.join(fixtures, "dir1")); + + testHelper.tick(function() { + var initialMissing = false; + wm.watchDirectory(path.join(fixtures, "dir3")).on( + "initial-missing", + () => { + initialMissing = true; + } + ); + testHelper.tick(function() { + for (const [, w] of wm.directoryWatchers) { + w.close(); + } + initialMissing.should.be.eql(true); + done(); + }); + }); + }); + + it("should not report directory as initial missing on the second watch when directory exists", function(done) { var wm = getWatcherManager({}); testHelper.dir("dir1"); wm.watchDirectory(path.join(fixtures, "dir1")); @@ -182,7 +205,7 @@ describe("DirectoryWatcher", function() { initialMissing = true; } ); - process.nextTick(() => { + testHelper.tick(function() { for (const [, w] of wm.directoryWatchers) { w.close(); }