var Filer = require('../..'); var util = require('../lib/test-utils.js'); var expect = require('chai').expect; describe('fs.watch', function() { beforeEach(util.setup); afterEach(util.cleanup); it('should be a function', function() { var fs = util.fs(); expect(typeof fs.watch).to.equal('function'); }); it('should get a change event when writing a file', function(done) { var fs = util.fs(); var watcher = fs.watch('/myfile', function(event, filename) { expect(event).to.equal('change'); expect(filename).to.equal('/myfile'); watcher.close(); done(); }); fs.writeFile('/myfile', 'data', function(error) { if(error) throw error; }); }); it('should get a change event when writing a file in a dir with recursive=true', function(done) { var fs = util.fs(); var watcher = fs.watch('/', { recursive: true }, function(event, filename) { expect(event).to.equal('change'); expect(filename).to.equal('/'); watcher.close(); done(); }); fs.writeFile('/myfile', 'data', function(error) { if(error) throw error; }); }); });