<commit_before><commit_msg>Add unit test for focus option.<commit_after>/*
  ******************

  Focus Option Tests

  ******************

  This spec has tests for checking proper behavior of the focus option.
*/

describe("Focus Option Tests", function() {

  var testSlider;

  var simulateMousedown = function(target, pos) {
    var myEvent = document.createEvent("MouseEvents");
    myEvent.initEvent("mousedown", true, true);
    myEvent.pageX = pos;
    myEvent.pageY = pos;
    target.dispatchEvent(myEvent);
  };

  it("should not be focused after value change when 'focus' is false", function() {
    testSlider = $("#testSlider1").slider({
      min  : 0,
      max  : 10,
      value: 0,
      focus: false,
      id   : "testSlider"
    });

    var hasFocus;
    $("#testSlider").find(".min-slider-handle").focus(function() {
      hasFocus = true;
    });

    simulateMousedown($("#testSlider").find(".slider-track-high").get(0), 1000);

    expect(hasFocus).toBe(undefined);
  });

  it("handle should be focused after value change when 'focus' is true", function() {
    testSlider = $("#testSlider1").slider({
      min  : 0,
      max  : 10,
      value: 0,
      focus: true,
      id   : "testSlider"
    });

    var hasFocus;
    $("#testSlider").find(".min-slider-handle").focus(function() {
      hasFocus = true;
    });

    simulateMousedown($("#testSlider").find(".slider-track-high").get(0), 1000);

    expect(hasFocus).toBe(true);
  });

  afterEach(function() {
    if (testSlider) {
      testSlider.slider("destroy");
      testSlider = null;
    }
  });
});
{'fraction_non_alphanumeric': 0.17919799498746866, 'fraction_numerical': 0.012531328320802004, 'mean_word_length': 3.0025062656641603, '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': '6249202', 'n_tokens_mistral': 515, 'n_tokens_neox': 494, 'n_words': 112}