-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from baalexander/set_max_listener
Sets unlimited number of event listeners.
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var expect = chai.expect; | ||
|
||
describe('ROS', function() { | ||
|
||
describe('callOnConnection', function() { | ||
it('should accept more than EventEmitter2\'s default listeners', function() { | ||
// By default, EventEmitter2 only accepts 10 listeners. When more than | ||
// the default, a 'warn' property is set on the listener. The firt part | ||
// of this test proves the 'warn' property will be set with default | ||
// EventEmitter2 settings. | ||
var callCount = 50; | ||
var eventEmitter = new EventEmitter2(); | ||
for (var i = 0; i < callCount; i++) { | ||
eventEmitter.on('foo', function() { }); | ||
} | ||
expect(eventEmitter._events['foo']).to.have.length(callCount); | ||
expect(eventEmitter._events['foo']).to.have.property('warned'); | ||
|
||
// The next part of this test shows that the 'warn' property is not set | ||
// for Ros, even with the same number of listeners as above. | ||
var ros = new ROSLIB.Ros(); | ||
for (var i = 0; i < callCount; i++) { | ||
ros.callOnConnection({}); | ||
} | ||
expect(ros._events['connection']).to.have.length(callCount); | ||
expect(ros._events['connection']).to.not.have.property('warned'); | ||
}); | ||
}); | ||
|
||
}); | ||
|