Skip to content

Commit

Permalink
more testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed May 6, 2015
1 parent 73a1b90 commit a9a5fb3
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ describe('index.test.js', function () {
this.watcher = wt.watch(fixtures, done);
});

afterEach(function () {
afterEach(function (done) {
try {
fs.rmdirSync(path.join(fixtures, '.createdir'));
} catch (err) {}
this.watcher.close();
setTimeout(done, 100);
});

it('should watch file change', function (done) {
Expand Down Expand Up @@ -69,6 +70,20 @@ describe('index.test.js', function () {
setTimeout(done, 200);
});

it('should not ignore hidden dir change with ignoreHidden option', function (done) {
done = pedding(2, done);

this.watcher.close();
this.watcher = wt.watch(fixtures, {ignoreHidden: false}, function() {
var dirpath = path.join(fixtures, '.createdir');
fs.mkdir(dirpath, done);

this.watcher.on('dir', function () {
done();
});
}.bind(this));
});

it('should watch subdir file change', function (done) {
done = pedding(2, done);
var filepath = path.join(fixtures, 'subdir', 'subfoo.txt');
Expand Down Expand Up @@ -175,4 +190,25 @@ describe('index.test.js', function () {
done();
});
});

it('should emit watch event twice', function(done) {
done = pedding(2, done);

this.watcher.close();
this.watcher = wt.watch([
path.join(fixtures, 'subdir'),
path.join(fixtures, 'subdir2')
]).on('watch', done.bind(null, null));
});

it('should emit watch-error event', function(done) {
var filepath = path.join(fixtures, 'not-exist');

this.watcher.close();
this.watcher = wt.watch(filepath)
.on('watch-error', function(err) {
err.dir.should.eql(filepath);
done();
});
});
});

0 comments on commit a9a5fb3

Please sign in to comment.