Skip to content

Commit 7b92f84

Browse files
more coverage
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
1 parent 82e2492 commit 7b92f84

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

test/parallel/test-fs-watch-recursive-prefix-sibling.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ tmpdir.refresh();
2828
(async () => {
2929
const root = fs.mkdtempSync(path.join(tmpdir.path, 'watch-prefix-'));
3030

31-
// Sibling names that share the prefix `foo` with the entry to delete.
31+
// Sibling names that share the prefix `foo` with the entries to delete.
3232
fs.mkdirSync(path.join(root, 'foo_bar'));
3333
fs.writeFileSync(path.join(root, 'foo_bar', 'file.txt'), '');
3434
fs.mkdirSync(path.join(root, 'foo_bar', 'somedir'));
35-
fs.mkdirSync(path.join(root, 'foo'));
3635
fs.writeFileSync(path.join(root, 'foo_'), '');
3736

37+
// `foo` (empty) exercises the exact-match branch of `#unwatchFiles`.
38+
fs.mkdirSync(path.join(root, 'foo'));
39+
40+
// `foo2` has descendants and exercises the `file + sep` prefix branch.
41+
fs.mkdirSync(path.join(root, 'foo2'));
42+
fs.writeFileSync(path.join(root, 'foo2', 'inside.txt'), '');
43+
fs.mkdirSync(path.join(root, 'foo2', 'sub'));
44+
3845
const events = [];
3946
const watcher = fs.watch(root, { recursive: true }, (eventType, filename) => {
4047
events.push({ eventType, filename });
@@ -44,6 +51,7 @@ tmpdir.refresh();
4451
await setTimeout(common.platformTimeout(200));
4552

4653
fs.rmdirSync(path.join(root, 'foo'));
54+
fs.rmSync(path.join(root, 'foo2'), { recursive: true });
4755

4856
// Wait long enough to capture any spurious follow-up events.
4957
await setTimeout(common.platformTimeout(500));

0 commit comments

Comments
 (0)