diff options
author | Brendan Ashworth <brendan.ashworth@me.com> | 2015-07-01 08:14:52 -0700 |
---|---|---|
committer | Brendan Ashworth <brendan.ashworth@me.com> | 2015-07-10 14:23:18 -0700 |
commit | 1afc0c9e86025693a157df935edbe72d7296055d (patch) | |
tree | b7afcdecb361f75bc878ed50a4edfbf0d8ceda17 /test/parallel/test-fs-watchfile.js | |
parent | 12bc397207dc1c4d63a390f5167b3a51a952ed83 (diff) | |
download | node-new-1afc0c9e86025693a157df935edbe72d7296055d.tar.gz |
fs: fix error on bad listener type
When the listener was truthy but NOT a function, fs.watchFile would
throw an error through the EventEmitter. This caused a problem because
it would only be thrown after the listener was started, which left the
listener on.
There should be no backwards compatability issues because the error was
always thrown, just in a different manner.
Also adds tests for this and other basic functionality.
PR-URL: https://github.com/nodejs/io.js/pull/2093
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-fs-watchfile.js')
-rw-r--r-- | test/parallel/test-fs-watchfile.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js new file mode 100644 index 0000000000..a64858ce0f --- /dev/null +++ b/test/parallel/test-fs-watchfile.js @@ -0,0 +1,17 @@ +'use strict'; + +const fs = require('fs'); +const assert = require('assert'); + +// Basic usage tests. +assert.throws(function() { + fs.watchFile('./some-file'); +}, /watchFile requires a listener function/); + +assert.throws(function() { + fs.watchFile('./another-file', {}, 'bad listener'); +}, /watchFile requires a listener function/); + +assert.throws(function() { + fs.watchFile(new Object(), function() {}); +}, /Path must be a string/); |