<commit_before>'use strict';

var test = require('tape');
var handle = require('../');

var ul = document.createElement('ul');
ul.setAttribute('style', 'display: none;');
document.body.appendChild(ul);

function click(element) {
  var event = new MouseEvent('click', {
    view: window,
    bubbles: true,
    cancelable: true
  });
  element.dispatchEvent(event);
}


test('handle(element, event, function)', function (t) {
  t.plan(4);<commit_msg>Add fallback for triggering events<commit_after>'use strict';

var test = require('tape');
var handle = require('../');

var ul = document.createElement('ul');
ul.setAttribute('style', 'display: none;');
document.body.appendChild(ul);

function click(element) {
  if (typeof MouseEvent === 'function' && typeof element.dispatchEvent === 'function') {
    var event = new MouseEvent('click', {
      view: window,
      bubbles: true,
      cancelable: true
    });
    element.dispatchEvent(event);
  } else {
    var event = document.createEvent('MouseEvent');
    event.initEvent('click', true, true);
    element.dispatchEvent(event);
  }
}


test('handle(element, event, function)', function (t) {
  t.plan(4);
{'fraction_non_alphanumeric': 0.17196904557179707, 'fraction_numerical': 0.0017196904557179708, 'mean_word_length': 4.4392523364485985, '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': '1595297', 'n_tokens_mistral': 354, 'n_tokens_neox': 354, 'n_words': 86}