diff --git a/test/add_test.js b/test/add_test.js index cfb1e89..6d2a274 100644 --- a/test/add_test.js +++ b/test/add_test.js @@ -35,7 +35,8 @@ exports.add = { gaze._addToWatched(files); var result = gaze.relative(null, true); test.deepEqual(sortobj(result), sortobj(expected)); - test.done(); + gaze.on('end', test.done); + gaze.close(); }, addLater: function(test) { test.expect(3); @@ -45,8 +46,8 @@ exports.add = { test.deepEqual(watcher.relative('sub'), ['one.js', 'two.js']); watcher.on('changed', function(filepath) { test.equal('two.js', path.basename(filepath)); + watcher.on('end', test.done); watcher.close(); - test.done(); }); fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'two.js'), 'var two = true;'); }); @@ -58,8 +59,8 @@ exports.add = { this.add('sub/two.js'); this.on('changed', function(filepath) { test.equal('two.js', path.basename(filepath)); + watcher.on('end', test.done); watcher.close(); - test.done(); }); setTimeout(function() { fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'two.js'), 'var two = true;'); diff --git a/test/api_test.js b/test/api_test.js index 64f2b30..0d09605 100644 --- a/test/api_test.js +++ b/test/api_test.js @@ -14,16 +14,16 @@ exports.api = { var result = this.relative(null, true); test.deepEqual(result['.'], ['Project (LO)/', 'nested/', 'one.js', 'sub/']); test.deepEqual(result['sub/'], ['one.js', 'two.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, func: function(test) { test.expect(1); var g = gaze('**/*', function(err, watcher) { test.deepEqual(watcher.relative('sub', true), ['one.js', 'two.js']); + g.on('end', test.done); g.close(); - test.done(); }); }, ready: function(test) { @@ -31,8 +31,8 @@ exports.api = { var g = new gaze.Gaze('**/*'); g.on('ready', function(watcher) { test.deepEqual(watcher.relative('sub', true), ['one.js', 'two.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, nomatch: function(test) { diff --git a/test/matching_test.js b/test/matching_test.js index 8261f2b..d6536ba 100644 --- a/test/matching_test.js +++ b/test/matching_test.js @@ -32,16 +32,16 @@ exports.matching = { var result = this.relative(null, true); test.deepEqual(result['.'], ['Project (LO)/', 'nested/', 'one.js', 'sub/']); test.deepEqual(result['sub/'], ['one.js', 'two.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, relativeDir: function(test) { test.expect(1); gaze('**/*', function() { test.deepEqual(this.relative('sub', true), ['one.js', 'two.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, globArray: function(test) { @@ -50,8 +50,8 @@ exports.matching = { var result = this.relative(null, true); test.deepEqual(sortobj(result['.']), sortobj(['one.js', 'Project (LO)/', 'nested/', 'sub/'])); test.deepEqual(sortobj(result['sub/']), sortobj(['one.js', 'two.js'])); + this.on('end', test.done); this.close(); - test.done(); }); }, globArrayDot: function(test) { @@ -59,8 +59,8 @@ exports.matching = { gaze(['./sub/*.js'], function() { var result = this.relative(null, true); test.deepEqual(result['sub/'], ['one.js', 'two.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, oddName: function(test) { @@ -68,8 +68,8 @@ exports.matching = { gaze(['Project (LO)/*.js'], function() { var result = this.relative(null, true); test.deepEqual(result['Project (LO)/'], ['one.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, addedLater: function(test) { diff --git a/test/relative_test.js b/test/relative_test.js index 492d8e5..7ab3559 100644 --- a/test/relative_test.js +++ b/test/relative_test.js @@ -23,6 +23,7 @@ exports.relative = { var gaze = new Gaze('addnothingtowatch'); gaze._addToWatched(files); test.deepEqual(gaze.relative('.', true), ['Project (LO)/', 'nested/', 'one.js', 'sub/']); - test.done(); + gaze.on('end', test.done); + gaze.close(); } }; diff --git a/test/rename_test.js b/test/rename_test.js index 5d2d496..b99f411 100644 --- a/test/rename_test.js +++ b/test/rename_test.js @@ -31,8 +31,8 @@ exports.watch = { watcher.on('renamed', function(newFile, oldFile) { test.equal(newFile, newPath); test.equal(oldFile, oldPath); + watcher.on('end', test.done); watcher.close(); - test.done(); }); fs.renameSync(oldPath, newPath); }); diff --git a/test/safewrite_test.js b/test/safewrite_test.js index ac76b93..bc4bc62 100644 --- a/test/safewrite_test.js +++ b/test/safewrite_test.js @@ -44,8 +44,8 @@ exports.safewrite = { if (times < 2) { setTimeout(simSafewrite, 1000); } else { + this.on('end', test.done); this.close(); - test.done(); } }); diff --git a/test/watch_test.js b/test/watch_test.js index 0f3d368..e1c3039 100644 --- a/test/watch_test.js +++ b/test/watch_test.js @@ -39,8 +39,8 @@ exports.watch = { var result = this.relative(null, true); test.deepEqual(result['sub/'], ['one.js']); test.notDeepEqual(result['.'], ['one.js']); + this.on('end', test.done); this.close(); - test.done(); }); }, changed: function(test) { @@ -163,7 +163,8 @@ exports.watch = { test.expect(1); gaze('non/existent/**/*', function(err, watcher) { test.ok(true); - test.done(); + watcher.on('end', test.done); + watcher.close(); }); }, differentCWD: function(test) {