<commit_before>'use strict';

describe('EventEmitter', function tests() {
  var EventEmitter = require('../').EventEmitter
    , chai = require('chai')
    , expect = chai.expect;

  chai.Assertion.includeStack = true;

  describe('EventEmitter#emit', function () {
    it('should return false when there are not events to emit', function () {
      var e = new EventEmitter();

      expect(e.emit('foo')).to.equal(false);
      expect(e.emit('bar')).to.equal(false);
    });

    it('emits with context', function (done) {
      var e = new EventEmitter()
        , context = 'bar';

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal(context);

        done();
      }, context).emit('foo', 'bar');
    });

    it('emits with context, multiple arguments (force apply)', function (done) {
      var e = new EventEmitter()
        , context = 'bar';

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal(context);

        done();
      }, context).emit('foo', 'bar', 1,2,3,4,5,6,7,8,9,0);
    });

    it('emits with context, multiple listeners (force loop)', function () {
      var e = new EventEmitter();

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal('bar');
      }, 'bar');

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal('foo');
      }, 'foo');

      e.emit('foo', 'bar');
    });

    it('emits with different contexts', function () {
      var e = new EventEmitter()
        , pattern = '';

      function writer() {
        pattern += this;
      }

      e.on('write', writer, 'foo');
      e.once('write', writer, 'bar');

      e.emit('write');
      expect(pattern).to.equal('foobar');
    });

    it('should return true when there are events to emit', function (done) {
      var e = new EventEmitter();

      e.on('foo', function () {
        process.nextTick(done);
      });<commit_msg>[test] Corrected test to duplicately check on/once<commit_after>'use strict';

describe('EventEmitter', function tests() {
  var EventEmitter = require('../').EventEmitter
    , chai = require('chai')
    , expect = chai.expect;

  chai.Assertion.includeStack = true;

  describe('EventEmitter#emit', function () {
    it('should return false when there are not events to emit', function () {
      var e = new EventEmitter();

      expect(e.emit('foo')).to.equal(false);
      expect(e.emit('bar')).to.equal(false);
    });

    it('emits with context', function (done) {
      var e = new EventEmitter()
        , context = 'bar';

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal(context);

        done();
      }, context).emit('foo', 'bar');
    });

    it('emits with context, multiple arguments (force apply)', function (done) {
      var e = new EventEmitter()
        , context = 'bar';

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal(context);

        done();
      }, context).emit('foo', 'bar', 1,2,3,4,5,6,7,8,9,0);
    });

    it('emits with context, multiple listeners (force loop)', function () {
      var e = new EventEmitter();

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal('bar');
      }, 'bar');

      e.on('foo', function (bar) {
        expect(bar).to.equal('bar');
        expect(this).to.equal('foo');
      }, 'foo');

      e.emit('foo', 'bar');
    });

    it('emits with different contexts', function () {
      var e = new EventEmitter()
        , pattern = '';

      function writer() {
        pattern += this;
      }

      e.on('write', writer, 'foo');
      e.on('write', writer, 'baz');
      e.once('write', writer, 'bar');
      e.once('write', writer, 'banana');

      e.emit('write');
      expect(pattern).to.equal('foobazbarbanana');
    });

    it('should return true when there are events to emit', function (done) {
      var e = new EventEmitter();

      e.on('foo', function () {
        process.nextTick(done);
      });
{'fraction_non_alphanumeric': 0.19021348045094746, 'fraction_numerical': 0.004797313504437515, 'mean_word_length': 2.498322147651007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3353645', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1292, 'n_words': 296}