Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
813 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var EventEmitter = require('../');
|
---|
4 | var assert = require('assert');
|
---|
5 |
|
---|
6 | var EE = new EventEmitter();
|
---|
7 | var m = function() {};
|
---|
8 | EE.on('foo', function() {});
|
---|
9 | assert.equal(1, EE.eventNames().length);
|
---|
10 | assert.equal('foo', EE.eventNames()[0]);
|
---|
11 | EE.on('bar', m);
|
---|
12 | assert.equal(2, EE.eventNames().length);
|
---|
13 | assert.equal('foo', EE.eventNames()[0]);
|
---|
14 | assert.equal('bar', EE.eventNames()[1]);
|
---|
15 | EE.removeListener('bar', m);
|
---|
16 | assert.equal(1, EE.eventNames().length);
|
---|
17 | assert.equal('foo', EE.eventNames()[0]);
|
---|
18 |
|
---|
19 | if (typeof Symbol !== 'undefined') {
|
---|
20 | var s = Symbol('s');
|
---|
21 | EE.on(s, m);
|
---|
22 | assert.equal(2, EE.eventNames().length);
|
---|
23 | assert.equal('foo', EE.eventNames()[0]);
|
---|
24 | assert.equal(s, EE.eventNames()[1]);
|
---|
25 | EE.removeListener(s, m);
|
---|
26 | assert.equal(1, EE.eventNames().length);
|
---|
27 | assert.equal('foo', EE.eventNames()[0]);
|
---|
28 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.