Skip to content

Commit

Permalink
test: check fs.watch filename on Linux and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Young committed May 21, 2017
1 parent 5fee2e8 commit 9bd4012
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/parallel/test-fs-watchfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,25 @@ fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) {
fs.unwatchFile(enoentFile);
}
}, 2));

// Watch events should callback with a filename
if (common.isLinux || common.isOSX) {
const dir = common.tmpDir + '/watch';

fs.mkdir(dir, common.mustCall(function(err) {
assert(!err);

fs.watch(dir, common.mustCall(function(eventType, filename) {
this._handle.close();
common.refreshTmpDir();
assert.strictEqual(filename, 'foo.txt');
}));

fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall((err) => {
if (err) {
common.refreshTmpDir();
assert(!err);
}
}));
}));
}

0 comments on commit 9bd4012

Please sign in to comment.