mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
593 B
19 lines
593 B
10 years ago
|
'use strict';
|
||
|
|
||
|
const common = require('../common');
|
||
|
const assert = require('assert');
|
||
|
const EventEmitter = require('events');
|
||
|
|
||
|
const emitter = new EventEmitter();
|
||
|
emitter.on('foo', function() {});
|
||
|
emitter.on('foo', function() {});
|
||
|
emitter.on('baz', function() {});
|
||
|
// Allow any type
|
||
|
emitter.on(123, function() {});
|
||
|
|
||
|
assert.strictEqual(EventEmitter.listenerCount(emitter, 'foo'), 2);
|
||
|
assert.strictEqual(emitter.listenerCount('foo'), 2);
|
||
|
assert.strictEqual(emitter.listenerCount('bar'), 0);
|
||
|
assert.strictEqual(emitter.listenerCount('baz'), 1);
|
||
|
assert.strictEqual(emitter.listenerCount(123), 1);
|