<commit_before>/* eslint-env jasmine */
/* eslint-disable no-multi-str */

describe('A toggle class module', function () {
  'use strict';

  var element, toggle;

  afterEach(function(){
    element.remove();
  });

  describe('when the search box is interacted with', function () {
    beforeEach(function () {
      element = $('\
        <form class="govuk-search" action="/search" method="get" role="search" data-module="toggle-class-on-focus">\
          <label for="search-box" class="search-label">Search GOV.UK</label>\
          <div class="search-wrapper">\
            <input type="search" id="search-box" name="q" title="Search" class="search-element search-input js-class-toggle">\
            <div class="search-element search-submit-wrapper">\
              <button type="submit" class="search-submit">Search</button>\
            </div>\
          </div>\
        </form>')

      $('body').append(element);
      toggle = new GOVUK.Modules.ToggleInputClassOnFocus();
      toggle.start(element);
    });

    it('applies the focus style on focus and removes it on blur', function () {
      var searchInput = element.find('.js-class-toggle');
      expect(searchInput.is('.focus')).toBe(false);
      searchInput.trigger('focus');
      expect(searchInput.is('.focus')).toBe(true);
      searchInput.trigger('blur');
      expect(searchInput.is('.focus')).toBe(false);
    });
  });

  describe('when the search box has a value', function () {
    beforeEach(function () {
      element = $('\
        <form class="govuk-search" action="/search" method="get" role="search" data-module="toggle-class-on-focus">\
          <label for="search-box" class="search-label">Search GOV.UK</label>\
          <div class="search-wrapper">\
            <input type="search" id="search-box" name="q" title="Search" value="Find this" class="search-element search-input js-class-toggle">\
            <div class="search-element search-submit-wrapper">\
              <button type="submit" class="search-submit">Search</button>\
            </div>\
          </div>\
        </form>')

      $('body').append(element);
      toggle = new GOVUK.Modules.ToggleInputClassOnFocus();
      toggle.start(element);
    });

    it('applies the focus style on load if the search box already has a value', function() {
      var searchInput = element.find('.js-class-toggle');
      expect(searchInput.is('.focus')).toBe(true);<commit_msg>Make test code more minimal<commit_after>/* eslint-env jasmine */
/* eslint-disable no-multi-str */

describe('A toggle class module', function () {
  'use strict';

  var element, toggle;

  afterEach(function(){
    element.remove();
  });

  describe('when the search box is interacted with', function () {
    beforeEach(function () {
      element = $('\
        <div data-module="toggle-class-on-focus">\
            <input type="search" class="js-class-toggle"/>\
        </div>')

      $('body').append(element);
      toggle = new GOVUK.Modules.ToggleInputClassOnFocus();
      toggle.start(element);
    });

    it('applies the focus style on focus and removes it on blur', function () {
      var searchInput = element.find('.js-class-toggle');
      expect(searchInput.is('.focus')).toBe(false);
      searchInput.trigger('focus');
      expect(searchInput.is('.focus')).toBe(true);
      searchInput.trigger('blur');
      expect(searchInput.is('.focus')).toBe(false);
    });
  });

  describe('when the search box has a value', function () {
    beforeEach(function () {
      element = $('\
        <div data-module="toggle-class-on-focus">\
            <input type="search" value="My search query" class="js-class-toggle">\
        </div>')

      $('body').append(element);
      toggle = new GOVUK.Modules.ToggleInputClassOnFocus();
      toggle.start(element);
    });

    it('applies the focus style on load if the search box already has a value', function() {
      var searchInput = element.find('.js-class-toggle');
      expect(searchInput.is('.focus')).toBe(true);
{'fraction_non_alphanumeric': 0.17267080745341615, 'fraction_numerical': 0.0, 'mean_word_length': 2.935483870967742, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '823181', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1149, 'n_words': 250}