<commit_before>describe('Map views search filter', function () {
  beforeEach(function () {
    var html = "<div data-role='page' id='page-map' style='width:200px; height:200px'>" +
        "<div id='search-box' class='ui-mini'>" +
        "<ul id='search-autocomplete' " +
        "data-role='listview' " +
        "data-theme='a' " +
        "data-filter-theme='a' " +
        "data-mini='true' " +
        "data-filter-mini='true' " +
        "data-filter='true' " +
        "data-filter-placeholder='Enter search string' " +
        "data-autodividers='true' " +
        "data-inset= 'true'>" +
        "</ul>" +
        "</div>" +
        "<div id='map_canvas'></div>" +
        "</div>";

    $('#stage').replaceWith(html);
    $.mobile.loadPage("#page-map");

    this.server = sinon.fakeServer.create();
    this.server.respondWith(
        "GET",
        Locations.prototype.url(),
        this.validResponse(this.fixtures.Locations.valid)
    );
  });

  afterEach(function () {
    $('#page-map').replaceWith("<div id='stage'></div>");
    this.server.restore();
  });

  describe('instantiation', function () {
    it('should initialize search view on map view initialization', function () {
      spyOn(SearchView.prototype, "initialize");
      new MapView({ el: $('#map_canvas') });
      expect(SearchView.prototype.initialize).toHaveBeenCalled();
    });

    it('should render search view on location refresh', function () {
      var mapView = new MapView({ el: $('#map_canvas') });
      spyOn(mapView.searchView, "render");
      runs(function () {
        mapView.locations.fetch();
        this.server.respond();
      });

      waitsFor(function () {
        return mapView.locations.length > 0;
      }, "Waiting for returning call", 1000);

      runs(function () {
        expect(mapView.searchView.render).toHaveBeenCalled();
      });
    });
  });
});
<commit_msg>MOB-128 Added tests for mobile keyboard handling in SearchView<commit_after>describe('Map views search filter', function () {
  beforeEach(function () {
    var html = "<div data-role='page' id='page-map' style='width:200px; height:200px'>" +
        "<div id='search-box' class='ui-mini'>" +
        "<ul id='search-autocomplete' " +
        "data-role='listview' " +
        "data-theme='a' " +
        "data-filter-theme='a' " +
        "data-mini='true' " +
        "data-filter-mini='true' " +
        "data-filter='true' " +
        "data-filter-placeholder='Enter search string' " +
        "data-autodividers='true' " +
        "data-inset= 'true'>" +
        "</ul>" +
        "</div>" +
        "<div id='map_canvas'></div>" +
        "</div>";

    $('#stage').replaceWith(html);
    $.mobile.loadPage("#page-map");

    this.server = sinon.fakeServer.create();
    this.server.respondWith(
        "GET",
        Locations.prototype.url(),
        this.validResponse(this.fixtures.Locations.valid)
    );
  });

  afterEach(function () {
    $('#page-map').replaceWith("<div id='stage'></div>");
    this.server.restore();
  });

  describe('instantiation', function () {
    it('should initialize search view on map view initialization', function () {
      spyOn(SearchView.prototype, "initialize");
      new MapView({ el: $('#map_canvas') });
      expect(SearchView.prototype.initialize).toHaveBeenCalled();
    });

    it('should render search view on location refresh', function () {
      var mapView = new MapView({ el: $('#map_canvas') });
      spyOn(mapView.searchView, "render");
      runs(function () {
        mapView.locations.fetch();
        this.server.respond();
      });

      waitsFor(function () {
        return mapView.locations.length > 0;
      }, "Waiting for returning call", 1000);

      runs(function () {
        expect(mapView.searchView.render).toHaveBeenCalled();
      });
    });
  });

  describe('mobile keyboard handling', function () {
    beforeEach(function () {
      spyOn(SearchView.prototype, "hideFilteredList");
      new MapView({ el: $('#map_canvas') });
    });

    it('should set type to search on the search input field', function () {
      expect($('#search-box input').attr('type')).toBe('search');
    });

    it('should prevent form submit to trigger blur event in search input field', function () {
      $('#search-box form').submit();
      expect(SearchView.prototype.hideFilteredList.calls.length).toBe(0);
    });
  });
});

{'fraction_non_alphanumeric': 0.18328478601837328, 'fraction_numerical': 0.005825677795205019, 'mean_word_length': 2.632221318144833, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '5900465', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1325, 'n_words': 238}