Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait until all listeners are removed before finishing test #71

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/add_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;');
});
Expand All @@ -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;');
Expand Down
6 changes: 3 additions & 3 deletions test/api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ 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) {
test.expect(1);
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) {
Expand Down
10 changes: 5 additions & 5 deletions test/matching_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -50,26 +50,26 @@ 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) {
test.expect(1);
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) {
test.expect(1);
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) {
Expand Down
3 changes: 2 additions & 1 deletion test/relative_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
2 changes: 1 addition & 1 deletion test/rename_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion test/safewrite_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ exports.safewrite = {
if (times < 2) {
setTimeout(simSafewrite, 1000);
} else {
this.on('end', test.done);
this.close();
test.done();
}
});

Expand Down
5 changes: 3 additions & 2 deletions test/watch_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down