function testAbled(isEnabled, testName, keyCode, eventProps, fn) {
  QUnit.test(testName, function (assert) {
    var $element = $(
      '<select>' +
        '<option>one</option>' +
        '<option>two</option>' +
      '</select>'
    );
    $('#qunit-fixture').append($element);
    $element.select2({ disabled: !isEnabled });

    var select2 = $element.data('select2');
    var $selection = select2.$selection;

    assert.notOk(select2.isOpen(), 'The instance should not be open');
    assert.equal(select2.isEnabled(), isEnabled);

    var event = buildKeyDownEvent(keyCode, eventProps);
    assert.ok(event.which, 'The event\'s key code (.which) should be set');

    $selection.trigger(event);

    fn(assert, select2);
  });
}
Wrapper function providing a select2 element with a given enabled/disabled
state that will get a given keydown event triggered on it. Provide an
assertion callback function to test the results of the triggered event.

@param  {Boolean}  isEnabled   the enabled state of the desired select2
                               element.
@param  {String}   testName    name for the test.
@param  {Number}   keyCode     used to set the 'which' attribute of the
                               keydown event.
@param  {Object}   eventProps  attributes to be used to build the keydown
                               event.
@param  {Function} fn          assertion callback to perform checks on the
                               result of triggering the event, receives the
                               'assert' variable for the test and the select2
                               instance behind the built <select> element.
@return {null}