<commit_before>var expect = require('chai').expect;
var Emitter = require('../build');

describe('on', function() {
  it('should add single event', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.on('foo', function(val) {
      foo = val;
    });

    emitter.on('foo', function(val) {
      foo += val;
    });

    emitter.emit('foo', 1);
    expect(foo).to.equal(2);
  });

  it('should add multiple events', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.on('foo bar', function(val, bar) {
      foo += val;
      if (bar) {
        foo += bar;
      }
    });

    emitter.emit('foo', 1);
    emitter.emit('bar', 1, 2);
    expect(foo).to.equal(4);
  });
});

describe('once', function() {
  it('should add events that will be fired once', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.once('foo', function(val) {<commit_msg>Added test for multiple events<commit_after>var expect = require('chai').expect;
var Emitter = require('../build');

describe('on', function() {
  it('should add a callback on an event', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.on('foo', function(val) {
      foo = val;
    });

    emitter.on('foo', function(val) {
      foo += val;
    });

    emitter.emit('foo', 1);
    expect(foo).to.equal(2);
  });

  it('should add same callback on multiple events ', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.on('foo bar', function(val, bar) {
      foo += val;
      if (bar) {
        foo += bar;
      }
    });

    emitter.emit('foo', 1);
    emitter.emit('bar', 1, 2);
    expect(foo).to.equal(4);
  });

  it('should add multiple events', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.on({
      foo: function(val) {
        foo += val;
      },
      bar: function(val) {
        foo -= val;
      }
    });

    emitter.emit('foo', 2);
    emitter.emit('bar', 1);
    expect(foo).to.equal(1);
  });
});

describe('once', function() {
  it('should add events that will be fired once', function() {
    var emitter = new Emitter();
    var foo = 0;

    emitter.once('foo', function(val) {
{'fraction_non_alphanumeric': 0.18486633439057545, 'fraction_numerical': 0.009968282736746714, 'mean_word_length': 2.4936708860759493, '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': '51133', 'n_tokens_mistral': 782, 'n_tokens_neox': 710, 'n_words': 194}