<commit_before>'use strict';

describe('ngOptions', function() {

  var scope, formElement, element, $compile, linkLog;

  function compile(html) {
    formElement = jqLite('<form name="form">' + html + '</form>');
    element = formElement.find('select');
    $compile(formElement)(scope);
    scope.$apply();
  }

  function setSelectValue(selectElement, optionIndex) {
    var option = selectElement.find('option').eq(optionIndex);
    selectElement.val(option.val());
    browserTrigger(element, 'change');
  }


  beforeEach(function() {
    this.addMatchers({
      toEqualSelectValue: function(value, multiple) {
        var errors = [];
        var actual = this.actual.val();

        if (multiple) {
          value = value.map(function(val) { return hashKey(val); });
          actual = actual || [];
        } else {
          value = hashKey(value);
        }

        if (!equals(actual, value)) {
          errors.push('Expected select value "' + actual + '" to equal "' + value + '"');
        }
        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualOption: function(value, text, label) {
        var errors = [];
        var hash = hashKey(value);
        if (this.actual.attr('value') !== hash) {
          errors.push('Expected option value "' + this.actual.attr('value') + '" to equal "' + hash + '"');
        }
        if (text && this.actual.text() !== text) {
          errors.push('Expected option text "' + this.actual.text() + '" to equal "' + text + '"');
        }
        if (label && this.actual.attr('label') !== label) {
          errors.push('Expected option label "' + this.actual.attr('label') + '" to equal "' + label + '"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualTrackedOption: function(value, text, label) {
        var errors = [];
        if (this.actual.attr('value') !== '' + value) {
          errors.push('Expected option value "' + this.actual.attr('value') + '" to equal "' + value + '"');
        }
        if (text && this.actual.text() !== text) {
          errors.push('Expected option text "' + this.actual.text() + '" to equal "' + text + '"');
        }
        if (label && this.actual.attr('label') !== label) {
          errors.push('Expected option label "' + this.actual.attr('label') + '" to equal "' + label + '"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualUnknownOption: function() {
        var errors = [];
        if (this.actual.attr('value') !== '?') {
          errors.push('Expected option value "' + this.actual.attr('value') + '" to equal "?"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualUnknownValue: function(value) {
        var errors = [];
        if (this.actual !== '?') {
          errors.push('Expected select value "' + this.actual + '" to equal "?"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      }
    });
  });

  beforeEach(module(function($compileProvider, $provide) {
    linkLog = [];

    $compileProvider
      .directive('customSelect', function() {
        return {
          restrict: "E",
          replace: true,
          scope: {
            ngModel: '=',
            options: '='
          },
          templateUrl: 'select_template.html',
          link: function(scope, $element, attributes) {
            scope.selectable_options = scope.options;
          }
        };
      })

      .directive('oCompileContents', function() {
        return {
          link: function(scope, element)  {
            linkLog.push('linkCompileContents');
            $compile(element.contents())(scope);
          }
        };
    });

    $provide.decorator('ngOptionsDirective', function($delegate) {<commit_msg>style(ngOptionsSpec): fix code style issue<commit_after>'use strict';

describe('ngOptions', function() {

  var scope, formElement, element, $compile, linkLog;

  function compile(html) {
    formElement = jqLite('<form name="form">' + html + '</form>');
    element = formElement.find('select');
    $compile(formElement)(scope);
    scope.$apply();
  }

  function setSelectValue(selectElement, optionIndex) {
    var option = selectElement.find('option').eq(optionIndex);
    selectElement.val(option.val());
    browserTrigger(element, 'change');
  }


  beforeEach(function() {
    this.addMatchers({
      toEqualSelectValue: function(value, multiple) {
        var errors = [];
        var actual = this.actual.val();

        if (multiple) {
          value = value.map(function(val) { return hashKey(val); });
          actual = actual || [];
        } else {
          value = hashKey(value);
        }

        if (!equals(actual, value)) {
          errors.push('Expected select value "' + actual + '" to equal "' + value + '"');
        }
        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualOption: function(value, text, label) {
        var errors = [];
        var hash = hashKey(value);
        if (this.actual.attr('value') !== hash) {
          errors.push('Expected option value "' + this.actual.attr('value') + '" to equal "' + hash + '"');
        }
        if (text && this.actual.text() !== text) {
          errors.push('Expected option text "' + this.actual.text() + '" to equal "' + text + '"');
        }
        if (label && this.actual.attr('label') !== label) {
          errors.push('Expected option label "' + this.actual.attr('label') + '" to equal "' + label + '"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualTrackedOption: function(value, text, label) {
        var errors = [];
        if (this.actual.attr('value') !== '' + value) {
          errors.push('Expected option value "' + this.actual.attr('value') + '" to equal "' + value + '"');
        }
        if (text && this.actual.text() !== text) {
          errors.push('Expected option text "' + this.actual.text() + '" to equal "' + text + '"');
        }
        if (label && this.actual.attr('label') !== label) {
          errors.push('Expected option label "' + this.actual.attr('label') + '" to equal "' + label + '"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualUnknownOption: function() {
        var errors = [];
        if (this.actual.attr('value') !== '?') {
          errors.push('Expected option value "' + this.actual.attr('value') + '" to equal "?"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      },
      toEqualUnknownValue: function(value) {
        var errors = [];
        if (this.actual !== '?') {
          errors.push('Expected select value "' + this.actual + '" to equal "?"');
        }

        this.message = function() {
          return errors.join('\n');
        };

        return errors.length === 0;
      }
    });
  });

  beforeEach(module(function($compileProvider, $provide) {
    linkLog = [];

    $compileProvider
      .directive('customSelect', function() {
        return {
          restrict: "E",
          replace: true,
          scope: {
            ngModel: '=',
            options: '='
          },
          templateUrl: 'select_template.html',
          link: function(scope, $element, attributes) {
            scope.selectable_options = scope.options;
          }
        };
      })

      .directive('oCompileContents', function() {
        return {
          link: function(scope, element) {
            linkLog.push('linkCompileContents');
            $compile(element.contents())(scope);
          }
        };
    });

    $provide.decorator('ngOptionsDirective', function($delegate) {
{'fraction_non_alphanumeric': 0.17195062923523718, 'fraction_numerical': 0.0012100677637947724, 'mean_word_length': 2.0363703159441586, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2345358', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2266, 'n_words': 466}