summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/fs_events_test.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/cli/tests/unit/fs_events_test.ts b/cli/tests/unit/fs_events_test.ts
index 0b30a070d..87f3ec241 100644
--- a/cli/tests/unit/fs_events_test.ts
+++ b/cli/tests/unit/fs_events_test.ts
@@ -26,7 +26,7 @@ unitTest({ perms: { read: true } }, function watchFsInvalidPath() {
});
async function getTwoEvents(
- iter: AsyncIterableIterator<Deno.FsEvent>,
+ iter: Deno.FsWatcher,
): Promise<Deno.FsEvent[]> {
const events = [];
for await (const event of iter) {
@@ -61,6 +61,8 @@ unitTest(
},
);
+// TODO(kt3k): This test is for the backward compatibility of `.return` method.
+// This should be removed at 2.0
unitTest(
{ perms: { read: true, write: true } },
async function watchFsReturn(): Promise<void> {
@@ -78,3 +80,21 @@ unitTest(
assertEquals(events, []);
},
);
+
+unitTest(
+ { perms: { read: true, write: true } },
+ async function watchFsClose(): Promise<void> {
+ const testDir = await Deno.makeTempDir();
+ const iter = Deno.watchFs(testDir);
+
+ // Asynchronously loop events.
+ const eventsPromise = getTwoEvents(iter);
+
+ // Close the watcher.
+ await iter.close();
+
+ // Expect zero events.
+ const events = await eventsPromise;
+ assertEquals(events, []);
+ },
+);