<commit_before>var testMouseTrap;

module("Discourse.KeyboardShortcuts", {
  setup: function() {
    var _bindings = {};

    testMouseTrap = {
      bind: function(bindings, callback) {
        var registerBinding = _.bind(function(binding) {
          _bindings[binding] = callback;
        }, this);

        if (_.isArray(bindings)) {
          _.each(bindings, registerBinding, this);
        }
        else {
          registerBinding(bindings);
        }
      },

      trigger: function(binding) {
        _bindings[binding].call();
      }
    };

    sandbox.stub(Discourse.URL, "routeTo");

    $("#qunit-fixture").html([
      "<article class='topic-post selected'>",
      "<a class='post-date'></a>" +
      "</article>",
      "<div class='notification-options'>",
      "  <ul>",
      "    <li data-id='0'><a></a></li>",
      "    <li data-id='1'><a></a></li>",
      "    <li data-id='2'><a></a></li>",
      "    <li data-id='3'><a></a></li>",
      "  </ul>",
      "</div>",
      "<table class='topic-list'>",
      "  <tr class='topic-list-item selected'><td>",
      "    <a class='title'></a>",
      "  </td></tr>",
      "</table>",
      "<div id='topic-footer-buttons'>",
      "  <button class='star'></button>",
      "  <button class='create'></button>",
      "  <button class='share'></button>",
      "</div>",
      "<button id='create-topic'></button>",
      "<div id='user-notifications'></div>",
      "<div id='search-button'></div>",
      "<div id='keyboard-help'></div>"
    ].join("\n"));
  },

  teardown: function() {
    $("#qunit-scratch").html("");
  }
});

var pathBindings = Discourse.KeyboardShortcuts.PATH_BINDINGS;

_.each(pathBindings, function(path, binding) {
  var testName = binding + " goes to " + path;

  test(testName, function() {
    Discourse.KeyboardShortcuts.bindEvents(testMouseTrap);
    testMouseTrap.trigger(binding);

    ok(Discourse.URL.routeTo.calledWith(path));
  });
});

var clickBindings = Discourse.KeyboardShortcuts.CLICK_BINDINGS;

_.each(clickBindings, function(selector, binding) {
  var bindings = binding.split(",");

  var testName = binding + " clicks on " + selector;<commit_msg>FIX: broken tests<commit_after>var testMouseTrap;

module("Discourse.KeyboardShortcuts", {
  setup: function() {
    var _bindings = {};

    testMouseTrap = {
      bind: function(bindings, callback) {
        var registerBinding = _.bind(function(binding) {
          _bindings[binding] = callback;
        }, this);

        if (_.isArray(bindings)) {
          _.each(bindings, registerBinding, this);
        }
        else {
          registerBinding(bindings);
        }
      },

      trigger: function(binding) {
        _bindings[binding].call();
      }
    };

    sandbox.stub(Discourse.URL, "routeTo");

    $("#qunit-fixture").html([
      "<article class='topic-post selected'>",
      "<a class='post-date'></a>" +
      "</article>",
      "<div class='notification-options'>",
      "  <ul>",
      "    <li data-id='0'><a></a></li>",
      "    <li data-id='1'><a></a></li>",
      "    <li data-id='2'><a></a></li>",
      "    <li data-id='3'><a></a></li>",
      "  </ul>",
      "</div>",
      "<table class='topic-list'>",
      "  <tr class='topic-list-item selected'><td>",
      "    <a class='title'></a>",
      "  </td></tr>",
      "</table>",
      "<div id='topic-footer-buttons'>",
      "  <button class='star'></button>",
      "  <button class='create'></button>",
      "  <button class='share'></button>",
      "</div>",
      "<button id='create-topic'></button>",
      "<div id='user-notifications'></div>",
      "<div id='site-map'></div>",
      "<div id='search-button'></div>",
      "<div id='current-user'></div>",
      "<div id='keyboard-help'></div>"
    ].join("\n"));
  },

  teardown: function() {
    $("#qunit-scratch").html("");
  }
});

var pathBindings = Discourse.KeyboardShortcuts.PATH_BINDINGS;

_.each(pathBindings, function(path, binding) {
  var testName = binding + " goes to " + path;

  test(testName, function() {
    Discourse.KeyboardShortcuts.bindEvents(testMouseTrap);
    testMouseTrap.trigger(binding);

    ok(Discourse.URL.routeTo.calledWith(path));
  });
});

var clickBindings = Discourse.KeyboardShortcuts.CLICK_BINDINGS;

_.each(clickBindings, function(selector, binding) {
  var bindings = binding.split(",");

  var testName = binding + " clicks on " + selector;
{'fraction_non_alphanumeric': 0.21189507010402533, 'fraction_numerical': 0.0018091361374943465, 'mean_word_length': 2.713685978169605, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 103, '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': '2889597', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1468, 'n_words': 227}