2014-05-23 20:53:50 +00:00
|
|
|
var Filer = require('../../../..');
|
|
|
|
var util = require('../../../lib/test-utils.js');
|
|
|
|
var expect = require('chai').expect;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NOTE: unlike node.js, which either doesn't give filenames (e.g., in case of
|
|
|
|
* fd vs. path) for events, or gives only a portion thereof (e.g., basname),
|
|
|
|
* we give full, abs paths always.
|
|
|
|
*/
|
|
|
|
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-watch-recursive.js", function() {
|
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
|
|
|
|
|
|
|
it('should get change event for writeFile() under a recursive watched dir', function(done) {
|
|
|
|
var fs = util.fs();
|
|
|
|
|
|
|
|
fs.mkdir('/test', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
|
|
|
|
fs.mkdir('/test/subdir', function(error) {
|
2014-03-07 16:54:14 +00:00
|
|
|
if(error) throw error;
|
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
var watcher = fs.watch('/test', {recursive: true});
|
|
|
|
watcher.on('change', function(event, filename) {
|
|
|
|
expect(event).to.equal('change');
|
|
|
|
// Expect to see that a new file was created in /test/subdir
|
|
|
|
expect(filename).to.equal('/test/subdir');
|
|
|
|
watcher.close();
|
|
|
|
done();
|
2014-03-07 16:54:14 +00:00
|
|
|
});
|
2014-05-23 20:53:50 +00:00
|
|
|
|
|
|
|
fs.writeFile('/test/subdir/watch.txt', 'world');
|
2014-03-07 16:54:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|