Skip to content

Commit

Permalink
removed unecesary SIGINT listeners
Browse files Browse the repository at this point in the history
better event cleanup in tests
  • Loading branch information
saadtazi committed Mar 10, 2015
1 parent 8a978e4 commit d0959b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/firefox_profile.js
Expand Up @@ -139,7 +139,6 @@ function FirefoxProfile(options) {
['exit', 'SIGINT'].forEach(function(event) {
process.addListener(event, self.onExit);
});
process.addListener('SIGINT', process.exit);
}

function deleteParallel(files, cb) {
Expand Down
17 changes: 12 additions & 5 deletions test/firefox_profile.js
Expand Up @@ -10,6 +10,7 @@ var path = require('path'),
describe('firefox_profile', function() {
var fp;
beforeEach(function() {
// default basic profile
fp = new FirefoxProfile();
});

Expand All @@ -19,7 +20,7 @@ describe('firefox_profile', function() {
}
});
afterEach(function(done) {
// will remove the onexit() call (that deletes the dir folder)
// will remove the onexit() calls (that deletes the dir folder)
// prevents warning:
// possible EventEmitter memory leak detected.
// X listeners added. Use emitter.setMaxListeners() to increase limit.
Expand All @@ -31,17 +32,18 @@ describe('firefox_profile', function() {
expect(fs.statSync(fp.profileDir).isDirectory()).to.be.true;
});

it('with string parameter, lock files should not be copied over', function() {
it('with string parameter, lock files should not be copied over', function(done) {
var fp = new FirefoxProfile(testProfiles.emptyProfile.path);
expect(fp.profileDir.slice(-5)).to.be.equal('-copy');
expect(fs.statSync(fp.profileDir).isDirectory()).to.be.true;
['.parentlock', 'lock', 'parent.lock'].forEach(function(lockFile) {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
fp.deleteDir(done);
});

it('should copy the profile into destinationDirectory if specified', function() {
it('should copy the profile into destinationDirectory if specified', function(done) {
var fp = new FirefoxProfile({ profileDirectory: testProfiles.emptyProfile.path,
destinationDirectory: testProfiles.dest
});
Expand All @@ -51,6 +53,8 @@ describe('firefox_profile', function() {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
// to clean events
fp.deleteDir(done);
});

});
Expand Down Expand Up @@ -85,7 +89,8 @@ describe('firefox_profile', function() {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
done();
// to clean events
fp.deleteDir(done);
});
});

Expand All @@ -103,6 +108,7 @@ describe('firefox_profile', function() {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
// to clean events
fp.deleteDir(done);
});
});
Expand All @@ -126,7 +132,8 @@ describe('firefox_profile', function() {
expect(fs.existsSync(path.join(fp.profileDir, lockFile))).to.be.false;
});
expect(fs.existsSync(path.join(fp.profileDir, 'empty.file'))).to.be.true;
done();
// to clean events
fp.deleteDir(done);
});
});

Expand Down

0 comments on commit d0959b5

Please sign in to comment.