<commit_before>describe('ComboStack test suite', function () {
  var fixtureInputElement
    , QUICK_INTERVAL = 50 // used to simulate "holding down"
    , SLOW_INTERVAL = 150 // used to simulate a quick individual keypress
    , SEPARATE_INTERVAL = 250 // used to simulate a slow individual keypress
                              // (separate from the previous keypress)
    , KEYCODE_A = 65
    , KEYCODE_B = 66
    , KEYCODE_C = 67
    , KEYCODE_D = 68


  function _generateKeyEvent(element, keyCode, eventName) {
    // KeyboardEvent apparently not supported in phantomjs.
    var e = document.createEvent('Event')
    e.keyCode = keyCode
    e.initEvent(eventName, {
      bubbles: true,
      cancelable: true
    })
    element.dispatchEvent(e)
  }

  function _generateKeyDownUpEvent(element, keyCode) {
    _generateKeyEvent(fixtureInputElement, keyCode, 'keydown')
    window.setTimeout(
      _generateKeyEvent.bind(this, fixtureInputElement, keyCode, 'keyup')
    , QUICK_INTERVAL)
  }

  // execute a keydown after timeout
  Object.prototype._keyDown = function _keyDown(element, keyCode, timeout) {
    timeout = timeout || 0
    return new Promise(function(resolve, reject) {
      window.setTimeout(function() {
        _generateKeyEvent(element, keyCode, 'keydown')
        resolve()
      }, timeout)
    })
  }

  // execute an immediate keyup
  Object.prototype._keyUp = function _keyUp(element, keyCode, timeout) {
    timeout = timeout || 0
    return new Promise(function(resolve, reject) {
      window.setTimeout(function() {
        _generateKeyEvent(element, keyCode, 'keyup')
        resolve()
      }, timeout
      )
    })
  }

  // execute an immediate keyDownUp
  function _keyDownUp(element, keyCode, timeout) {
    timeout = timeout || 0
    console.log(timeout)
    return new Promise(function(resolve, reject) {
      window.setTimeout(function() {
        _generateKeyDownUpEvent(element, keyCode, 'keyup')
        resolve()
      }, timeout)
    })
  }


  beforeEach(function(done) {
    fixtureInputElement = document.createElement('input')
    done()
  })

  it('should pass an empty test', function (done) {
    done();
  });

  it('should pass single keypresses', function (done) {

    addCombinationEventListener(fixtureInputElement, function(result) {
      result.should.deep.equal([KEYCODE_A])
      done()
    })
    _keyDownUp(fixtureInputElement, KEYCODE_A)
  })

  it('should pass multiple keypresses of 2 different keys together', function (done) {
    addCombinationEventListener(fixtureInputElement, function(result) {
      console.log(result)
      result.should.deep.equal([[KEYCODE_A, KEYCODE_B]])
      done()
    })
    _keyDown(fixtureInputElement, KEYCODE_A)
      .then(_keyDown.bind(null, fixtureInputElement, KEYCODE_B))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_B))
  })

  it('should pass 2 spaced single keypresses of the same letter within the same combination', function(done) {
    addCombinationEventListener(fixtureInputElement, function(result) {
      console.log(result)
      result.should.deep.equal([KEYCODE_A, KEYCODE_A])
      done()
    })
    _keyDown(fixtureInputElement, KEYCODE_A)
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
      .then(_keyDown.bind(null, fixtureInputElement, KEYCODE_A, SLOW_INTERVAL))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))



    // _keyDownUp(fixtureInputElement, KEYCODE_A)
    //   .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A, 200))


  })

});
<commit_msg>add multiple separate keypress test<commit_after>describe('ComboStack test suite', function () {
  var fixtureInputElement
    , QUICK_INTERVAL = 50 // used to simulate "holding down"
    , SLOW_INTERVAL = 150 // used to simulate a quick individual keypress
    , SEPARATE_INTERVAL = 250 // used to simulate a slow individual keypress
                              // (separate from the previous keypress)
    , KEYCODE_A = 65
    , KEYCODE_B = 66
    , KEYCODE_C = 67
    , KEYCODE_D = 68


  function _generateKeyEvent(element, keyCode, eventName) {
    // KeyboardEvent apparently not supported in phantomjs.
    var e = document.createEvent('Event')
    e.keyCode = keyCode
    e.initEvent(eventName, {
      bubbles: true,
      cancelable: true
    })
    element.dispatchEvent(e)
  }

  function _generateKeyDownUpEvent(element, keyCode) {
    _generateKeyEvent(fixtureInputElement, keyCode, 'keydown')
    window.setTimeout(
      _generateKeyEvent.bind(this, fixtureInputElement, keyCode, 'keyup')
    , QUICK_INTERVAL)
  }

  // execute a keydown after timeout
  Object.prototype._keyDown = function _keyDown(element, keyCode, timeout) {
    timeout = timeout || 0
    return new Promise(function(resolve, reject) {
      window.setTimeout(function() {
        _generateKeyEvent(element, keyCode, 'keydown')
        resolve()
      }, timeout)
    })
  }

  // execute an immediate keyup
  Object.prototype._keyUp = function _keyUp(element, keyCode, timeout) {
    timeout = timeout || 0
    return new Promise(function(resolve, reject) {
      window.setTimeout(function() {
        _generateKeyEvent(element, keyCode, 'keyup')
        resolve()
      }, timeout
      )
    })
  }

  // execute an immediate keyDownUp
  function _keyDownUp(element, keyCode, timeout) {
    timeout = timeout || 0
    console.log(timeout)
    return new Promise(function(resolve, reject) {
      window.setTimeout(function() {
        _generateKeyDownUpEvent(element, keyCode, 'keyup')
        resolve()
      }, timeout)
    })
  }


  beforeEach(function(done) {
    fixtureInputElement = document.createElement('input')
    done()
  })

  it('should pass an empty test', function (done) {
    done();
  });

  it('should pass single keypresses', function (done) {

    addCombinationEventListener(fixtureInputElement, function(result) {
      result.should.deep.equal([KEYCODE_A])
      done()
    })
    _keyDownUp(fixtureInputElement, KEYCODE_A)
  })

  it('should pass multiple keypresses of 2 different keys together', function (done) {
    addCombinationEventListener(fixtureInputElement, function(result) {
      result.should.deep.equal([[KEYCODE_A, KEYCODE_B]])
      done()
    })
    _keyDown(fixtureInputElement, KEYCODE_A)
      .then(_keyDown.bind(null, fixtureInputElement, KEYCODE_B))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_B))
  })

  it('should pass 2 spaced single keypresses of the same letter within the same combination', function(done) {
    addCombinationEventListener(fixtureInputElement, function(result) {
      result.should.deep.equal([KEYCODE_A, KEYCODE_A])
      done()
    })
    _keyDown(fixtureInputElement, KEYCODE_A)
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
      .then(_keyDown.bind(null, fixtureInputElement, KEYCODE_A, SLOW_INTERVAL))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
  })

  it('should pass 2 spaced single keypresses of the same letter with separate combination', function(done) {
    addCombinationEventListener(fixtureInputElement, function(result) {
      result.should.deep.equal([KEYCODE_A, KEYCODE_A])
      done()
    })
    _keyDown(fixtureInputElement, KEYCODE_A)
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
      .then(_keyDown.bind(null, fixtureInputElement, KEYCODE_A, SLOW_INTERVAL))
      .then(_keyUp.bind(null, fixtureInputElement, KEYCODE_A))
  })

});

{'fraction_non_alphanumeric': 0.10680766688697951, 'fraction_numerical': 0.006080634500991408, 'mean_word_length': 3.4375366568914956, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3376473', 'n_tokens_mistral': 2347, 'n_tokens_neox': 2255, 'n_words': 497}