<commit_before>function fireEvent(node, eventName) {
  var event = document.createEvent('MouseEvents')
  // https://developer.mozilla.org/en-US/docs/Web/API/event.initMouseEvent
  event.initEvent(
    eventName, true, true, this, 0,
    event.screenX, event.screenY, event.clientX, event.clientY,
    false, false, false, false,
    0, null
  )
  event.button = 1
  event.which = null
  node.dispatchEvent(event)
}

describe('Core specs', function() {

  var counter = 0, $, $$

  before(function() {
    $ = document.querySelector.bind(document)
    $$ = document.querySelectorAll.bind(document)
    html = document.createElement('div')
    html.innerHTML =
      '<a class="tag-a" href="#">A</a>' +
      '<a class="tag-b" href="#fruit">B</a>' +
      '<a class="tag-c" href="#fruit/apple">C</a>' +
      '<a class="tag-d" href="#fruit/orange">D</a>' +
      '<a class="tag-e" href="#search?keyword=test&limit=30">E</a>' +
      '<a class="tag-f" href="/">F</a>' +
      '<a class="tag-g" href="/fruit">G</a>' +
      '<a class="tag-h" href="/fruit/apple">H</a>' +
      '<a class="tag-i" href="/fruit/orange">I</a>' +
      '<a class="tag-j" href="/search?keyword=test&limit=30">J</a>' +
      '<a class="tag-k prevented" href="mailto:<EMAIL>">K</a>' +
      '<a class="tag-l prevented" href="http://somewhereelse.io/">L</a>' +
      '<a class="tag-m prevented" href="/download/" download>M</a>' +
      '<a class="tag-n" href="/other/" targer="_self">N</a>' +
      '<a class="tag-o" href="/other/" targer="_blank">O</a>' +
      '<a class="tag-p prevented" href="/no-go/">no go</a>' +
      '<p class="tag-z">O</p>'
    document.body.appendChild(html)

    // fix the page reload issue
    Array.prototype.slice.call($$('.prevented')).forEach(function(el) {
      el.addEventListener('click', function(e) {
        e.preventDefault()
      })
    })
  })

  after(function() {
    if (window.history && window.history.replaceState) {
      window.history.replaceState(null, '', window.location.pathname)
    }
  })

  afterEach(function() {
    counter = 0
    route.stop() // detouch all routings
    route.base() // reset base
    route.parser() // reset parser
    route.start() // start router again
  })

  it('detects the params', function() {
    route(function(first, second) {
      counter++
      expect(first).to.be('mummypowder')
      expect(['logo-and-key', 'http%3A%2F%2Fxxx.yyy']).to.contain(second)
    })
    route('mummypowder/logo-and-key')
    route('mummypowder/http%3A%2F%2Fxxx.yyy')
    expect(counter).to.be(2)
  })

  it('detects link clicked', function() {
    route(function(first, second) {
      counter++
      expect(first).to.be('fruit')
      expect(['apple', 'orange']).to.contain(second)
    })
    fireEvent($('.tag-c'), 'click')
    fireEvent($('.tag-d'), 'click')
    expect(counter).to.be(2)
  })

  it('ignore link clicked in some cases', function() {
    route(function() {
      counter++
    })
    fireEvent($('.tag-z'), 'click')
    expect(counter).to.be(0)
    fireEvent($('.tag-n'), 'click')
    expect(counter).to.be(1)
    expect(counter).to.be(1)

    fireEvent($('.tag-k'), 'click')
    fireEvent($('.tag-l'), 'click')
    fireEvent($('.tag-m'), 'click')
    fireEvent($('.tag-o'), 'click')

    console.log(counter)

    expect(counter).to.be(1)<commit_msg>removed: console log from the tests<commit_after>function fireEvent(node, eventName) {
  var event = document.createEvent('MouseEvents')
  // https://developer.mozilla.org/en-US/docs/Web/API/event.initMouseEvent
  event.initEvent(
    eventName, true, true, this, 0,
    event.screenX, event.screenY, event.clientX, event.clientY,
    false, false, false, false,
    0, null
  )
  event.button = 1
  event.which = null
  node.dispatchEvent(event)
}

describe('Core specs', function() {

  var counter = 0, $, $$

  before(function() {
    $ = document.querySelector.bind(document)
    $$ = document.querySelectorAll.bind(document)
    html = document.createElement('div')
    html.innerHTML =
      '<a class="tag-a" href="#">A</a>' +
      '<a class="tag-b" href="#fruit">B</a>' +
      '<a class="tag-c" href="#fruit/apple">C</a>' +
      '<a class="tag-d" href="#fruit/orange">D</a>' +
      '<a class="tag-e" href="#search?keyword=test&limit=30">E</a>' +
      '<a class="tag-f" href="/">F</a>' +
      '<a class="tag-g" href="/fruit">G</a>' +
      '<a class="tag-h" href="/fruit/apple">H</a>' +
      '<a class="tag-i" href="/fruit/orange">I</a>' +
      '<a class="tag-j" href="/search?keyword=test&limit=30">J</a>' +
      '<a class="tag-k prevented" href="mailto:<EMAIL>">K</a>' +
      '<a class="tag-l prevented" href="http://somewhereelse.io/">L</a>' +
      '<a class="tag-m prevented" href="/download/" download>M</a>' +
      '<a class="tag-n" href="/other/" targer="_self">N</a>' +
      '<a class="tag-o" href="/other/" targer="_blank">O</a>' +
      '<a class="tag-p prevented" href="/no-go/">no go</a>' +
      '<p class="tag-z">O</p>'
    document.body.appendChild(html)

    // fix the page reload issue
    Array.prototype.slice.call($$('.prevented')).forEach(function(el) {
      el.addEventListener('click', function(e) {
        e.preventDefault()
      })
    })
  })

  after(function() {
    if (window.history && window.history.replaceState) {
      window.history.replaceState(null, '', window.location.pathname)
    }
  })

  afterEach(function() {
    counter = 0
    route.stop() // detouch all routings
    route.base() // reset base
    route.parser() // reset parser
    route.start() // start router again
  })

  it('detects the params', function() {
    route(function(first, second) {
      counter++
      expect(first).to.be('mummypowder')
      expect(['logo-and-key', 'http%3A%2F%2Fxxx.yyy']).to.contain(second)
    })
    route('mummypowder/logo-and-key')
    route('mummypowder/http%3A%2F%2Fxxx.yyy')
    expect(counter).to.be(2)
  })

  it('detects link clicked', function() {
    route(function(first, second) {
      counter++
      expect(first).to.be('fruit')
      expect(['apple', 'orange']).to.contain(second)
    })
    fireEvent($('.tag-c'), 'click')
    fireEvent($('.tag-d'), 'click')
    expect(counter).to.be(2)
  })

  it('ignore link clicked in some cases', function() {
    route(function() {
      counter++
    })
    fireEvent($('.tag-z'), 'click')
    expect(counter).to.be(0)
    fireEvent($('.tag-n'), 'click')
    expect(counter).to.be(1)
    expect(counter).to.be(1)

    fireEvent($('.tag-k'), 'click')
    fireEvent($('.tag-l'), 'click')
    fireEvent($('.tag-m'), 'click')
    fireEvent($('.tag-o'), 'click')

    expect(counter).to.be(1)
{'fraction_non_alphanumeric': 0.22057936028968014, 'fraction_numerical': 0.006336753168376584, 'mean_word_length': 3.171806167400881, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 73, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6579461', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2332, 'n_words': 373}