<commit_before>import simulant from 'simulant';

import loadMochaFixture from './helpers/loadMochaFixture';

import Elements from '../src/elements';

describe('on', function() {

  let fixture;
  beforeEach(function() {
    loadMochaFixture('fixtures/test.html');
    fixture = document.getElementById('fixture');
  });

  describe('mouse events', function() {

    it('calls callback on mouse click', function() {
      const element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(element).on('click', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(1);
      expect(events).to.have.deep.property('[0].event.type', 'click');
    });

    it('calls callback on delegated mouse click', function() {
      const nav = fixture.querySelector('nav'),
        element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(nav).on('click', 'a', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(1);
      expect(events).to.have.deep.property('[0].event.type', 'click');
    });

    it('doesn\'t callback on delegated mouse click if selector doesn\'t match', function() {
      const nav = fixture.querySelector('nav'),
        element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(nav).on('click', '#text__paragraphs', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(0);
    });

  });

});<commit_msg>Added 1 more test for on()<commit_after>import simulant from 'simulant';

import loadMochaFixture from './helpers/loadMochaFixture';

import Elements from '../src/elements';

describe('on', function() {

  let fixture;
  beforeEach(function() {
    loadMochaFixture('fixtures/test.html');
    fixture = document.getElementById('fixture');
  });

  describe('mouse events', function() {

    it('calls callback on mouse click', function() {
      const element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(element).on('click', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(1);
      expect(events).to.have.deep.property('[0].event.type', 'click');
    });

    it('calls callback on delegated mouse click', function() {
      const nav = fixture.querySelector('nav'),
        element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(nav).on('click', 'a', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(1);
      expect(events).to.have.deep.property('[0].event.type', 'click');
    });

    it('doesn\'t call callback on delegated mouse click if selector doesn\'t match', function() {
      const nav = fixture.querySelector('nav'),
        element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(nav).on('click', '#text__paragraphs', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(0);
    });

    it('doesn\'t call callback on delegated mouse click on same element', function() {
      const element = fixture.querySelector('a[href="#text__headings"]'),
        events = [];
      new Elements(element).on('click', 'a', function(event, data) {
        events.push({ event, data });
      });
      simulant.fire(element, 'click');
      expect(events).to.be.an('array').that.has.length(0);
    });
  });

});
{'fraction_non_alphanumeric': 0.18576084231637002, 'fraction_numerical': 0.0030082727500626723, 'mean_word_length': 3.3558951965065504, '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': '3574041', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1183, 'n_words': 230}