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.

28 lines
813 B

4 years ago
  1. 'use strict';
  2. var EventEmitter = require('../');
  3. var assert = require('assert');
  4. var EE = new EventEmitter();
  5. var m = function() {};
  6. EE.on('foo', function() {});
  7. assert.equal(1, EE.eventNames().length);
  8. assert.equal('foo', EE.eventNames()[0]);
  9. EE.on('bar', m);
  10. assert.equal(2, EE.eventNames().length);
  11. assert.equal('foo', EE.eventNames()[0]);
  12. assert.equal('bar', EE.eventNames()[1]);
  13. EE.removeListener('bar', m);
  14. assert.equal(1, EE.eventNames().length);
  15. assert.equal('foo', EE.eventNames()[0]);
  16. if (typeof Symbol !== 'undefined') {
  17. var s = Symbol('s');
  18. EE.on(s, m);
  19. assert.equal(2, EE.eventNames().length);
  20. assert.equal('foo', EE.eventNames()[0]);
  21. assert.equal(s, EE.eventNames()[1]);
  22. EE.removeListener(s, m);
  23. assert.equal(1, EE.eventNames().length);
  24. assert.equal('foo', EE.eventNames()[0]);
  25. }